How do you reset state now since connectRouter is passed inside combineReducer and a history object is passed when creating the root reducer?
Previous way:
const appReducer = combineReducers({
general: GeneralReducer
});
const rootReducer = (state, action) => {
if(action.type == 'RESET') {}
return appReducer(state, action);
};
export default rootReducer;
I am facing the same problem :(
@jjdp @svenadlung You can try following
const createAppReducer = (history) => combineReducers({
general: GeneralReducer,
router: connectRouter(history)
});
const initialState = {
general: {},
router: {}
};
const createRootReducer = (history) => (state, action) => {
if (action.type == 'RESET') {
return initialState;
}
return createAppReducer(history)(state, action);
};
export default createRootReducer;
Perfect, thx @sgal !
Hey folks, If anyone else comes across this issue, and is still having problems (specifically receiving the error Uncaught Could not find router reducer in state tree, it must be mounted under "router"), I fixed it by following @sgal's suggestion above but not setting anything for initialState.router.
If you manually set initiaState.router's value as shown above, you will receive this error.
Most helpful comment
@jjdp @svenadlung You can try following