Tell us what’s happening:
Describe your issue in detail here.
Hello, in the default case of my switch statement I am returning state, but in the solution they return defaultState. My method passes all of the tests, but could someone please explain the correct solution? state and defaultState seem to be the same value and that this is a minor detail, but since these are objects I am worried about object reference errors.
Your code so far
const defaultState = {
authenticated: false
};
const authReducer = (state = defaultState, action) => {
// Change code below this line
switch (action.type) {
case 'LOGIN':
return { authenticated: true };
case 'LOGOUT':
return { authenticated: false };
default:
return state;
}
// Change code above this line
};
const store = Redux.createStore(authReducer);
const loginUser = () => {
return {
type: 'LOGIN'
}
};
const logoutUser = () => {
return {
type: 'LOGOUT'
}
};
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36
Challenge: Redux - Use a Switch Statement to Handle Multiple Actions
Link to the challenge: