We all know that if state changed then DOM will refresh, if we dispatched an action but the DOM not refreshed, definitely you triggered side effect.
Here is a debug checklist:
Common Mistakes when utilizing spread operator
const rv = (state === undefined) ? defaultState : { ...state };
switch (action.type) {
case LOGIN_ERROR:
/*
Spread Operator only do shallow copy here
the grand child are still referenced to state
that means: after spread operator, rv.loginPage.msg === state.loginPage.msg
*/
/* YOU ARE CHANGING STATE DIRECTLY */
rv.loginPage.msg = {
...state.loginPage.msg,
...action.data,
}
return rv;
}
const rv = (state === undefined) ? defaultState : { ...state };
switch (action.type) {
case LOGIN_ERROR:
/*
spread the object for each generation
*/
rv.loginPage = {
...state.loginPage, /* we spreaded the child */
msg: {
...state.loginPage.msg, /* we spreaded the grandchild */
...action.data,
},
};
return rv;
}