[BUG?] Router: `isRouting()` immediately returns `false` when transition is not completed

Hey guys, I noticed isRouting changes immediately from true to false if transition happens on the same page (for instance, when I change query params and createAsync looks at these params), so isRouting becomes false when there's no new data yet. Is it intended behavior? isRouting works as expected (waits until the data comes) when the route is changing.
// pseudo code:
const isRouting = useIsRouting();
const [$searchParams, setSearchParams] = useSearchParams();

const data = createAsync(() => getSomeData({ page: $searchParams.page }));

return <>
<div classList={{ inactive: isRouting() }}>{data.latest?.smth}</div>
<button type="button" onClick={() => setSearchParams({page: +$searchParams.page + 1})}>Next page</button>
</>
// pseudo code:
const isRouting = useIsRouting();
const [$searchParams, setSearchParams] = useSearchParams();

const data = createAsync(() => getSomeData({ page: $searchParams.page }));

return <>
<div classList={{ inactive: isRouting() }}>{data.latest?.smth}</div>
<button type="button" onClick={() => setSearchParams({page: +$searchParams.page + 1})}>Next page</button>
</>
4 Replies
Brendonovich
Brendonovich2mo ago
latest won’t suspend while data is fetching is there is data from a previous fetch, so it won’t take part in the transition
elite174
elite1742mo ago
yes, but it works when the page is changing hmm ok, looks like I got this, thanks!
Brendonovich
Brendonovich2mo ago
I assume when the page is changing there’s no data available yet, so latest does suspend It’s just that after the initial fetch latest doesn’t re-suspend
elite174
elite1742mo ago
Yes, you're right
Want results from more Discord servers?
Add your server