layout route component get all child routes and context
Is it possible to create this structure
use route.tsx as the layout but get all "child" routes and the context of them
in the route.tsx layout i want to loop over the children to create a navigation menu and get the context of those child components to create the label
4 Replies
compatible-crimsonOP•11mo ago
Tried this but cant use the useRouteContext if it isnt matched
this seems to work but i get an type error on this
rare-sapphire•11mo ago
did you have a look at https://tanstack.com/router/v1/docs/framework/react/api/router/useChildMatchesHook
?
TanStack | High Quality Open-Source Software for Web Developers
Headless, type-safe, powerful utilities for complex workflows like Data Management, Data Visualization, Charts, Tables, and UI Components.

compatible-crimsonOP•11mo ago
Yes i did, this only returns direct child matches, i want to render all possible children of that layout.
so the settings layout could have /settings/account and /settings/company
right now i fixed it with
this does feel a bit hacky though.
rare-sapphire•11mo ago
router.routesById would be less hacky?