Question about ensureQueryData
I have the following beforeLoad in tanstack router
On the queryClient i have a default
staleTime: 1000 * 20, of 20 seconds. I noticed that the onboarding variable doesn't update if i navigate to a different page in the same _auth layout after 20 seconds. If there is data in the query cache, it will never fetch new data even if it is stale?
Switching to:
Seems to take in consideration the staleTime
Thank you!
(Notice i do not use that query in another place. I saw that if i also have a "useSuspenseQuery" in combination with the ensureQueryData in the loader for different api calls, that one works. So i guess the useSuspenseQuery invalidates ( triggers a refetch ) if the query is stale )3 Replies
exotic-emeraldOP•11mo ago
Nvm…it seems I found the reason in the docs. Sorry for the stupid question
Will leave this here if anybody faces the same misunderstanding
exotic-emeraldOP•11mo ago

exotic-emeraldOP•11mo ago
You can pass revalidateIfStale: true for that