Redux: Handle an Action in the Store code doesn't work

Tell us what’s happening:

Why doesn’t this code work?

Your code so far


const defaultState = {
login: false
};

const reducer = (state = defaultState, action) => {
// change code below this line
action.type === 'LOGIN'
? {login: true}
: 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/80.0.3987.163 Safari/537.36.

Challenge: Handle an Action in the Store

Link to the challenge:

Hi, your logic is perfectly fine but seems like you forgot to return the new state :slight_smile: .

return action.type === 'LOGIN'
? {login: true}
: state