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
absent-sapphire•6mo ago
please add a complete minimal example to showcase what you try to do
other-emerald•6mo ago
Why dont you place the navbar directly in the
__root.tsx
file?
otherwise, just use a main layout, like
or
ratty-blushOP•6mo 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
other-emerald•6mo 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
ratty-blushOP•6mo ago
got it, appreciate the help
question how does re-rendering work with pathless routes does it rerender the whole route and child routes?
absent-sapphire•6mo 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
ratty-blushOP•6mo 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.
absent-sapphire•6mo ago
what does the navbar do? does it subscribe to router state?