Describe the bug
Hey, I want to know why there's component race condition for a pending component when i throw redirects. The logic's simple - show a spinner for good looks right away, but check the user role in the background - then redirect to their dedicated routes
// __root.tsx
export const Route = createRootRouteWithContext<RouterContext>()({
component: RootComponent,
pendingMs: 0, // show spinnner immediately - error when `beforeLoad` is over. Set it to `1000` - no error
pendingMinMs: 500,
pendingComponent: () => {
return <SpinnerScreen />;
},
errorComponent: (props) => <pre>{JSON.stringify(props.error, null, 2)}</pre>,
async beforeLoad({ context, location }) {
const user = await context.qc.ensureQueryData(sessionQueryOptions);
if (location.pathname.startsWith(WelcomeRoute.to)) return;
const redir = match(user.type)
.with("edit_op", () =>
!location.pathname.startsWith(EditSalesRoute.to)
? redirect({
to: EditSalesRoute.to,
replace: true,
})
: undefined,
)
.with(...)
.exhaustive();
if (redir) throw redir;
},
});
and you can see a white screen
when i reload the page it will be normal
when i set pendingMs to a 1000, a spinner will not show up but the error will be gone, luckily
though i need a spinner right away
Your minimal, reproducible example
Steps to reproduce
Expected behavior
No react dom error must appear
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
Windows 10, Zen browser latest
Tanstack Query adapter
None
TanStack Query version
5.90.12
TypeScript version
5.9.3
Additional context
No response
Describe the bug
Hey, I want to know why there's component race condition for a pending component when i throw redirects. The logic's simple - show a spinner for good looks right away, but check the user role in the background - then redirect to their dedicated routes
and you can see a white screen
when i reload the page it will be normal
when i set pendingMs to a 1000, a spinner will not show up but the error will be gone, luckily
though i need a spinner right away
Your minimal, reproducible example
Steps to reproduce
Expected behavior
No react dom error must appear
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
Windows 10, Zen browser latest
Tanstack Query adapter
None
TanStack Query version
5.90.12
TypeScript version
5.9.3
Additional context
No response