Getting multiple re-renders
When I load the app, and when my routes change, my Root Route seems to re-render.
Im generating the logs using the
useLogRenders hook from this example from an issue I saw on github which could be a similar problem?
In the logs screenshot, I've got no react components being rendered in my Root route.
https://stackblitz.com/edit/tanstack-router-bxtshb?file=src/routes/__root.tsxStackBlitz
Router Basic File Based Example (forked) - StackBlitz
Run official live example code for Router Basic File Based, created by Tanstack on StackBlitz

7 Replies
fascinating-indigoOP•2y ago
https://codesandbox.io/p/devbox/friendly-shape-f5mdcr?file=/src/main.tsx:27,1
Here's a reproduction using
navigate and Linkconscious-sapphire•2y ago
yeah most likely this is the same as https://github.com/TanStack/router/issues/1112
GitHub
Entire app re-mounted 6 times on navigate and on every link hover.....
Describe the bug When clicking on a link, the entire root component gets re-rendered and re-mounted 6 times. Also, hovering on a link causes it to get re-mounted as well. This means that absolutely...
fascinating-indigoOP•2y ago
ah ok, i figured that could be the case. Will see if things change when it gets fixed 🙂
@Tanner Linsley just following up on this from the other thread - this is a bug with the router, and not something we have control over, right? the reproduction isn't using any hooks that subscribe to data.
If its a bug, is there anything we can do temporarily in our app to mitigate this while the fix is being worked on? I'm finding that since using the router to perform my navigations (we were previously using a home-grown custom implementation), in-app navigation is really sluggish. Just wanted to see if its the re-renders thats causing this, since I'm not too sure what else it could be....
optimistic-gold•2y ago
Not really. Just wait for me to fix it
fascinating-indigoOP•2y ago
things are so much faster in v1.15.17!
optimistic-gold•2y ago
Huzzah!
Sad that that's the standard for just about every other router that isn't based on fine-grained state
fascinating-indigoOP•2y ago
oh wow really? thats insane