Redux - Use const for Action Types

Tell us what’s happening:
Describe your issue in detail here.

I do not understand why my code here doesn’t work . I can not find the error.

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 (iPhone; CPU iPhone OS 15_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.4 Mobile/15E148 Safari/604.1

Challenge: Redux - Use const for Action Types

Link to the challenge:

You have decleared const, use these const LOGIN and LOGOUT in authReducer() and action creators instead of strings. You can do it by removing quotes .
Mod Edit: SOLUTION REMOVED

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

Ok. I understood. From now I will not give solutions directly. I will just give hints for the solution.

@SonuShivcharan thank you. I’ve already solved it :ok_hand:t4:

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