Is there any problem in my code it's not accepting my code

Tell us what’s happening:

Your code so far


// Change code below this line
const LOGIN = 'LOGIN';
const LOGOUT = 'LOGOUT';
// Change code above this line

const defaultState = {
authenticated: false
};

const authReducer = (state = defaultState, action) => {

switch (action.type) {
  case LOGIN:
    return {
      authenticated: true
    }

  case LOGOUT:
    return {
      authenticated: false
    }

  default:
    return state;

}

};

const store = Redux.createStore(authReducer);

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

const logoutUser = () => {
return {
  type: 'LOGOUT'
}
};

Your browser information:

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

Challenge: Use const for Action Types

Link to the challenge:

You need to change these two at the bottom too.

1 Like

The error message is:

The action creators and the reducer should reference the LOGIN and LOGOUT constants.

These are your action creators:

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

const logoutUser = () => {
return {
  type: 'LOGOUT'
}
};

You are not using the constants - you have written out the string. That works, but it is not following the instructions (which are trying to teach you best practices).

If I change that, your code passes for.

2 Likes