Routing Question
Unanswered
Transvaal lion posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/3.png)
Transvaal lionOP
I am creating an application with multiple calculators and have a header that is shared across the parent layout of the /calculators folder that needs to know which calculator is currently being used to generate a title dynamically. The folder structure is structured like so...
/calculators (folder)
/calculator-1
calculator.tsx
page.tsx
/calculator-2
calculator.tsx
page.tsx
layout.tsx
page.tsx
I am currently not using any brackets, quotes, ellipsis, etc. Is there an easy way to get the current calculator to update the header? Attempting to get params returns undefined/null since none of the folders are bracketed. Any help would be super appreciated.
/calculators (folder)
/calculator-1
calculator.tsx
page.tsx
/calculator-2
calculator.tsx
page.tsx
layout.tsx
page.tsx
I am currently not using any brackets, quotes, ellipsis, etc. Is there an easy way to get the current calculator to update the header? Attempting to get params returns undefined/null since none of the folders are bracketed. Any help would be super appreciated.
5 Replies
![Avatar](https://cdn.discordapp.com/embed/avatars/3.png)
Burmese
There is no reason you couldn't make
/calculators/layout.tsx
take a client component that updates when the user selects their calculator.![Avatar](https://cdn.discordapp.com/avatars/657067112434499595/c78dd8e985ede1ad50c31ac682dd91a1.webp?size=256)
risky
Other than the fact that you shouldn't make a layout a client component because of the amount of things that won't work well (ie metadata)
Also you can have server component layout and just import client component into it (and use usePathname to know which page you are on)
![Avatar](https://cdn.discordapp.com/embed/avatars/3.png)
Burmese
This is exactly what I am saying.
Oh, I mean the layout would just take some client component, not be a client component. Calc type can get passed in via the url.