Redux - Handle an Action in the Store

Tell us what’s happening:
Describe your issue in detail here.
why 1 test case not passing
Your code so far

const defaultState = {
  login: false
};

const reducer = (state = defaultState, action) => {
  // Change code below this line
if(action.type ==='LOGIN'){
  state.login : true
}
else {
  return state;
}
  // Change code above this line
};

const store = Redux.createStore(reducer);

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36

Challenge: Redux - Handle an Action in the Store

Link to the challenge:

You’re almost there.

Here:

if(action.type ==='LOGIN'){
  state.login : true
}

First of all, you are not returning anything. And it looks like you were thinking that “state.login” was some kind of object property?

You need to return the new state there. This is how state starts out:

const defaultState = {
 login: false
};

So, you want to return an object with that “shape”, but just change the data as needed.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.