Redux handle an action in store

const defaultState = {
login: false
};

const reducer = (state, action) => {
// change code below this line
if(action.type === “LOGIN”){
state.login = false
};
return state;
// change code above this line
};

const store = Redux.createStore(reducer, defaultState);

const loginAction = () => {
return {
type: ‘LOGIN’
}
};

store.dispatch(loginAction());

expected result: Dispatching loginAction should update the login property in the store state to true.

my solution passes all test expect this one

Dispatching loginAction should update the login property in the store state to true

The blurb tells you to create a state object with login set to true

{login: true}

the answer should look something like this

if(action.type === ‘LOGIN’ ){
return {login: true}
} return state;

5 Likes