-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
Describe the bug
When using the persistor, what we wanted to do was serve up the stored data as stale and immediately refetch. That is not the default behavior, so what we tried to do is set refetchOnMount
to 'always'
. This does not make it refetch on initial mount.
The second thing we tried is: when our app loads we invalidate all queries using queryClient.invalidateQueries()
. But queries that haven't initialized yet are not invalidated. When not using the persistor, this makes total sense, but when you are using it, this leads to some very unexpected behavior.
Your minimal, reproducible example
https://stackblitz.com/edit/tanstack-query-xma74mr5?file=src%2FPosts.vue
Steps to reproduce
- Go to page
- Refresh page within 5m (stale time)
- Data is not re-fetched on page load
Expected behavior
I expect queryClient.invalidateQueries()
or refetchOnMount: 'always'
to make the data stale and refetched.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- OS mac OS
- Browser Chrome & FF
Tanstack Query adapter
vue-query
TanStack Query version
5.89.0
TypeScript version
No response
Additional context
I love Tanstack Query and wanna use it but I just want the functionality like SWRV where the page initially loads with local storage data (that is marked as stale) and then immediately begins re-fetching.