Closed quentinbrohan closed 3 years ago
@quentinbrohan This would be the same process you'd do for clearing redux state in a normal app.
As a quick example, you could do something like this, which would clear your store.
import { combineReducers } from '@reduxjs/toolkit';
import { api } from './yourService';
import { logout } from '../features/auth';
const appReducer = combineReducers({
[api.reducerPath]: api.reducer,
});
const rootReducer = (state, action) => {
if (logout.match(action)) {
state = undefined;
}
return appReducer(state, action);
};
export default rootReducer;
@msutkowski Thanks, perfect and simple !
Hell-O,
I can't find a way to clear all caches from 2 services (tripApi, userApi) when a user logout. I would like to clear everything (queries, mutations, etc) when the user click on the logout button as well as clearing my RTK slice.
I tried to create a mutation with invalidating parameters and playing with onStart but without success, and I've found nothing about it on internet and in the typing.
Any tips? Thanks