I want to reset the state of the redux store on logout without removing some values. I referred to this link : How to reset the state of a Redux store?. How can i keep some values intact in the store after logout.
Asked
Active
Viewed 379 times
1 Answers
0
This answer can be slightly modified to suit your case.
Instead of setting state = undefined;
completely, you can use merge() methods to clear only specific properties while retaining the others.
const rootReducer = (state, action) => {
if (action.type === 'USER_LOGOUT') {
return state.merge({
value1: undefined,
value2: undefined,
...
});
}
return appReducer(state, action)
}

Ramya Ramanathan
- 78
- 7