Replies: 1 comment
-
Ok I realize now why TanStack doesn't make looping over nav items the recmmended approach. For a basic nav of links then yes looping over a list is fine If you need to pass parameters or search query items into those links then you loose the type safety that stand alone I still think there should be an in built easier way to loop over my routes to generate navigation. 80-90% of navigation menus are just basic routes with no params or search query parts attached. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
routeTree
is an auto generated variable that holds all of your site navigation paths in it.So it would make sense to be able to use that variable to loop over those paths to generate website navigation menus.
There are multiple problems making this a more painful task than it needs to be.
routeTree.children
types are incorrect (Incorrect type onrouteTree.children
#4766)routeTree.children
doesn't have a nested style structure of children having children, all of the paths are at the top level attached to the route, so this makes managing multi-level navigation more difficult.createFileRoute
function. This means that we have to manually create an object matching up paths to the nav label.This was my attempt at building a nav using
routeTree.children
:https://stackblitz.com/edit/github-ytjdgxla?file=src%2Fcomponents%2FNav.tsx
I think the least disruptive fix would be to create a
useNavigation()
hook or provide arouteTree.navigation
property for getting the navigation in a nested format. Properties also need to be added to thecreateFileRoute
function that give us the ability to definenavLabel
andnavOrder
.Beta Was this translation helpful? Give feedback.
All reactions