Closed
Description
The problem
There's a scenario, which is pretty common:
- user logs in
- some user data is fetched
- user logs out
- different user logs in and for a moment sees previous user's data
Normally, all user data should be deleted after log out, but there's no API for that at the moment.
I've tried setQueryData
function to clear some queries, but it didn't work for me, since it doesn't make those query stale.
I've managed to clear cache like this:
import { queries } from 'react-query';
function handleLogout() {
queries.length = 0;
}
But I'm not sure if it is safe to do this, since this is not a public API.
Proposed solution
Introduce clearQueries
function, which will:
- clear all queries if called without arguments
- clear all queries except those provided as first argument.
The second option may be useful for applications, which are partly public. This will allow to clear user data cache, but keep public data cache.
Let me know do you think about that
Metadata
Metadata
Assignees
Labels
No labels