Skip to content Skip to sidebar Skip to footer

Why My Redux State Not Updating

state not updating.when action is dispatched the state should update to isAuthenticated to true..but the state not updating..redux returning the initial state not the updated state

Solution 1:

You are not updating the payload data in your reducer

exportdefault(state = initialState, action)=> {
      switch(action.type){
        case SET_CURRENT_USER:
        return {...state, user: action.payload} //update user here
        }
        ...
        default: return state;
      }
    }

the above code uses es6 features and the assumption made is isAuthenticated and error are part of the initial state.

You are just returning the same JSON which is why your state is not updating.

Post a Comment for "Why My Redux State Not Updating"