In React we have a best practice not modify state directly i.e. mutation... It is also important in Redux...
/* initial state */
export const usersStartState = { users: { isLoggedIn: false } }
export default function users(state = usersStartState, action) {
switch (action.type) {
case actionTypes.users.IS_LOGGED_IN:
return Object.assign({}, state,
state.users.isLoggedIn = true)
case actionTypes.users.IS_LOGGED_OUT:
return Object.assign({}, state,
state.users.isLoggedIn = false)
default:
return state
}
};
The above doesn't work, but can anyone help me how to properly update that nested objects property?