How to make dynamic component in nested layouts
Answered
Erkan posted this in #help-forum
ErkanOP
Hello, I would like to know if there is a way to have nested layout components take over the layout which is in its root. Let me explain :
In my case I have a layout in my dashboard which contains a sidebar, this sidebar contains main navigation buttons.
Then I have a settings folder which is nested in the dashboard root like /dashboard/settings.
The settings location has its own layout, but I would like this layout to have a completely different sidebar with specific navigation.
The problem I'm currently encountering is that the dashboard root layout takes over the settings layout.
(I would like to use as many RSCs as possible)
My idea: I think I should keep only one sidebar in the main layout, and find a way to catch the /settings path to change the content injected into my component sidebar. But I wonder if there isn't a more formal way.
I don't know if it's relevant but I'll post a photo (I hide the useless places)
And here is a path example :
In my case I have a layout in my dashboard which contains a sidebar, this sidebar contains main navigation buttons.
Then I have a settings folder which is nested in the dashboard root like /dashboard/settings.
The settings location has its own layout, but I would like this layout to have a completely different sidebar with specific navigation.
The problem I'm currently encountering is that the dashboard root layout takes over the settings layout.
(I would like to use as many RSCs as possible)
My idea: I think I should keep only one sidebar in the main layout, and find a way to catch the /settings path to change the content injected into my component sidebar. But I wonder if there isn't a more formal way.
I don't know if it's relevant but I'll post a photo (I hide the useless places)
And here is a path example :
L /dashboard
L page.tsx
L layout.tsx (generic side bar)
L /settings
L page.tsx
L layout.tsx (settings sidebar)`2 Replies
Answer
ErkanOP
here is the solution guys