Repository navigation
Replies: 3 comments 10 replies
|
removeQueries is what you are looking for I believe. Can you show a reproduction of what is not working for you please |
|
I solved this issue with queryClient.clear(); |
|
this worked for me: import { onlineManager } from '@tanstack/react-query';
// ...
await queryClient.cancelQueries();
onlineManager.setOnline(false);
queryClient.clear();
// perform logout, redirect, etc
i'm aware of the query it would be great if there was a simple, global way to achieve what |
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 want that after the user logout of my application the react query removes its cache, however i was searching in the official docs i found the methods:

queryClient.removeQueries(key);<-- Removes the queries ??queryClient.invalidateQueries(key);<-- Invalidate all queries or a specefic query, but refetching it and saves it again in the cache:-/queryClient.clear();<-- Remove the cache?, to me not work this.The methods not work for me :(
Then, is there some method that react query provides me to remove the cache without refetch them again?
it's a problem the cache because i need that when the user logout, the app remove all user old state and the cache too.
All reactions