Using constants for action type

Tell us what’s happening:
i dont know what is wrong with the code , it looks fine but i cannot identify the problem

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 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36.

Challenge: Use const for Action Types

Link to the challenge:

Use declared constants everywhere in your code, not stings;

1 Like