Cache not clearing with removeQueries()
I am calling
queryClient.removeQueries() before logging out. However, I still see the cache has data. What could I be doing wrong?8 Replies
compatible-crimson•3y ago
Are you calling it with queryKeys? Pretty sure that requires queryKeys and what you might want is
queryClient.clear() instead.
I actually ran into a similar problem with forgetting to clear zustand stores which lead me to full page redirect after logout. Felt like a nice way to sanity cleanse my app.deep-jadeOP•3y ago
Oh I see. Will try! Thanks
Still facing this issue
.clear() also dosen't worksensitive-blue•3y ago
Show a reproduction
deep-jadeOP•3y ago
Not v sure about how to do that.. I can paste code that I am using but it is really as basic as
useQuery(...) to store in the cache and then queryClient.removeQueries() to clear the cache before logging outsensitive-blue•3y ago
Show logout code
deep-jadeOP•3y ago
provincial-silver•3y ago
removeQueries will remove data from the cache - you can see that if you use the devtools. It will not re-render your app (because that would likely trigger useQuery to re-run since there is no data in the cache anymore).
deep-jadeOP•3y ago
I'm seeing the cache using the dev tools and I still see data in the cache after logging out. Not quite sure what's going on
Found the issue! I should have been clearing the cache after logging out so that none of the queries would be re-fetched