Redux: Use a switch case to handle multiple actions

Fail to understand why the test cases are failing for this logic. The console.log statement returns the state object as expected.
Describe your issue in detail here.
Is it necessary to have a new variable to track the state object and return it? I am using the dot notation here to change the value of authenticated.

  **Your code so far**

const defaultState = {
authenticated: false

const authReducer = (state = defaultState, action) => {
switch (action.type) {
case ‘LOGIN’:
state.authenticated = true;
case ‘LOGOUT’:
state.authenticated = false;
return defaultState
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/95.0.4638.69 Safari/537.36 Edg/95.0.1020.53

Challenge: Use const for Action Types

Link to the challenge:

I believe Redux expects a new state instead of manipulating the current one.

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