Hi, I really love this react-redux starter kit, thanks for the great work.
I have implemented a simple authentication flow and I'm trying to reset the whole redux state at the user logout, but I'm not able.
I've take inspiration by this snippet on SO:
const appReducer = combineReducers({
/* your app鈥檚 top-level reducers */
})
const rootReducer = (state, action) => {
if (action.type === 'USER_LOGOUT') {
state = undefined
}
return appReducer(state, action)
}
but I don't understand how/where I can apply the solution above at the starter-kit.
In these past days i've already tried without success to enhance the makeRootReducer function with a _high order reducer_ for resetting the state, but It doesn't seem the right solution.
Does anyone have some hints to point me in the right direction? Thanks!
I don't think the problem is related to this repo but you can try this. (not tested)
export const makeRootReducer =
(asyncReducers) =>
(state, action) =>
combineReducers({
// reducers...
router,
...asyncReducers
})(action.type === 'STATE_RESET' ? undefined : state, action)
Thanks a lot @kolpav ! It works, I tried with very similar approaches in these past days but without success.
This just made my day 馃嵒 !
It works! Thanks!
Most helpful comment
I don't think the problem is related to this repo but you can try this. (not tested)