Open cschmatzler opened 3 weeks ago
I've been experiencing this too, however my code might be a little different. Rendering the actual app is delayed by almost 1 second.
const InnerApp = () => {
const auth = useAuthStore();
if (auth.loading) {
return <div>Loading...</div>;
}
return (
<ThemeProvider theme={lightTheme}>
<CssBaseline />
<RouterProvider router={router} context={{ auth }} />
<Toaster />
</ThemeProvider>
);
};
export default () => {
return (
<StrictMode>
<QueryClientProvider client={queryClient}>
<InnerApp />
</QueryClientProvider>
</StrictMode>
);
};
I also checked the performance tab in devtools and it looks like nothing is happening (the selected range is when nothing is rendered)
As a temporary fix, add pendingMinMs: 0
.
I just noticed it happening on all the lazy routes.
React profiler shows:
looking at the offending function: https://github.com/TanStack/router/blob/0e16429b0d8af8d65040c06af3b895f4e10b310a/packages/react-router/src/Match.tsx#L19
It does wait for pendingMinMs
ms before loading the match.
Is there a catch to just setting pendingMinMs: 0
?
I just saw this issue and added the temporary fix and my app feels way faster now... This needs a fix.
Describe the bug
When adding
beforeLoad
to a route (even an empty one), the router gets mounted and then displays a white page for approx. 400ms before the actual page is rendered.Your Example Website or App
https://stackblitz.com/github/tanstack/router/tree/main/examples/react/quickstart-file-based
Steps to Reproduce the Bug or Issue
beforeLoad: () => {}
to any page - I chose the about page.Expected behavior
Simply adding the
beforeLoad
option should not materially change load times.Screenshots or Videos
https://github.com/user-attachments/assets/eaa57efa-7c2f-4fad-b64d-a9f10017e9cf
Platform
Additional context
No response