How to add a _pathlesslayout on the route node
I want make my pathless route a navbar on my root node that i can keep so it doesn't get re-rendered al the time. Is virtual routes the only way to do this?
8 Replies
unwilling-turquoise•9mo ago
please add a complete minimal example to showcase what you try to do
absent-sapphire•9mo ago
Why dont you place the navbar directly in the
__root.tsx file?
otherwise, just use a main layout, like
or
wise-whiteOP•9mo ago
@ferretwithabéret Thanks that first one worked out. Mentally I kept thinking the index.tsx had to be in the same path as the __root.tsx. I didn't want a navbar on every page. just the first index page
absent-sapphire•9mo ago
both of the above are equivalent, they literally do the same thing
it is your preference which dictates which one you want to use
wise-whiteOP•9mo ago
got it, appreciate the help
question how does re-rendering work with pathless routes does it rerender the whole route and child routes?
unwilling-turquoise•9mo ago
no why? router only re-renders routes if something you subscribed to changed.
if that does not answer your question please give some example where you are concerned
wise-whiteOP•9mo ago
lets say i have a navbar as a pathless route. I click on a link in the navbar. Is the navbar suppose to rerender with the outlet or just the outlet? I'm using react scan and hmr and it seems everything rerenders when i would think just the outlet changes. Just trying to get a mental model of what renders and what doesn't when something changes or when it goes to a new route.
unwilling-turquoise•9mo ago
what does the navbar do? does it subscribe to router state?