T
TanStack•2y ago
fascinating-indigo

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.
const Root = () => {
useLogRenders('Root');
return (
<></>
);
};

export const rootRoute = createRootRouteWithContext<AppContext>()({
validateSearch: appSearchParamsSchema,
component: Root,
})
const Root = () => {
useLogRenders('Root');
return (
<></>
);
};

export const rootRoute = createRootRouteWithContext<AppContext>()({
validateSearch: appSearchParamsSchema,
component: Root,
})
https://stackblitz.com/edit/tanstack-router-bxtshb?file=src/routes/__root.tsx
StackBlitz
Router Basic File Based Example (forked) - StackBlitz
Run official live example code for Router Basic File Based, created by Tanstack on StackBlitz
No description
7 Replies
fascinating-indigo
fascinating-indigoOP•2y ago
conscious-sapphire
conscious-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-indigo
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
optimistic-gold•2y ago
Not really. Just wait for me to fix it
fascinating-indigo
fascinating-indigoOP•2y ago
things are so much faster in v1.15.17!
optimistic-gold
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-indigo
fascinating-indigoOP•2y ago
oh wow really? thats insane

Did you find this page helpful?