Redux - Use const for Action Types

Tell us what’s happening:

Describe your issue in detail here.
i get an error like this.
The action creators and the reducer should reference the LOGIN and LOGOUT constants.
and i have not the line
//change the code below this line and
// change the code above this line

Your code so far

const LOGIN = 'LOGIN';
const LOGOUT = 'LOGOUT';

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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36

Challenge Information:

Redux - Use const for Action Types

It means that you should replace all the plain text ‘LOGIN’ and ‘LOGOUT’ by the constants you have created.

2 Likes

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