T
TanStack3y ago
conscious-sapphire

react query cached and not up to date

Hi, I'm using tan stack query for authentication api calling React router dom for routing So basically in my auth route I'm logging as a user I'm using use Mutation for calling login api endpoint then redirects to the homepage route which I have a loader calls the api before component load and verify the user credentials with useQuery. Problem appears if Im deleting credentials it redirects to login page and loggin again with right info the query is still cached with old data. With invalidateQueries isnt working. It only works if I'm refreshing the page again. NOTE query created in the loader function
2 Replies
conscious-sapphire
conscious-sapphireOP3y ago
If detailed infos are required pls send me a dm
unwilling-turquoise
unwilling-turquoise3y ago
I believe maybe you can do queryClient.resetQueries() when logging out

Did you find this page helpful?