Repository navigation
Advice on when to use and how to clear cache in defineQuery #667
Replies: 1 comment 5 replies
|
The stale data comes from removing an entry that is still in use. I reproduced it on 1.4.8 with a component that stays mounted across logout/login (a layout, for example). With So yes, await queryCache.invalidateQueries({ key: itemsKeys.all }, false)It marks the entries stale without refetching, so your guard's As for |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I recently had a problem where I needed to clear cache from a reusable query. I have the following
When a user logs out, I want to clear the cache without refetching, therefore I had
I have this in my routes file
This led to some strange behaviours where the next logged in user got the items of the previous user.
I am not sure why I ended up with the stale data. One odd issue is that the query had zero observers when logging in again.
What fixed it in the end was to use this in logout
I haven't fully tested this, but would this have been better:
In this scenario I did not need to pass any query params to the backend via fetchItems, should I have simply used useQuery?
All reactions