**T * The counterReducer should increment and decrement the state.
-
Failed:The
authReducershould toggle thestateofauthenticatedbetweentrueandfalse. -
Failed: The store
stateshould have two keys:count, which holds a number, andauth, which holds an object. Theauthobject should have a property ofauthenticated, which holds a boolean.:**
I have implemented it in difference ways and it kept showing me this same answer, error.
**Your cconst INCREMENT = ‘INCREMENT’;
const DECREMENT = ‘DECREMENT’;
const counterReducer = (state = 0, action) => {
switch(action.type) {
case INCREMENT:
return state + 1;
case DECREMENT:
return state - 1;
default:
return state;
}
};
const LOGIN = ‘LOGIN’;
const LOGOUT = ‘LOGOUT’;
const authReducer = (state = {authenticated: false}, action) => {
switch(action.type) {
case LOGIN:
return {
authenticated: true
}
case LOGOUT:
return {
authenticated: false
}
default:
return state;
}
};
// Define the root reducer here
const rootReducer = Redux.combineReducers({
count: counterReducer,
auth: authReducer
});
ode so far**
const INCREMENT = 'INCREMENT';
const DECREMENT = 'DECREMENT';
const counterReducer = (state = { counter: 0 }, action) => {
switch (action.type) {
case "INCREMENT":
return {
counter: state.counter + 1,
};
case "DECREMENT":
return {
counter: state.counter - 1,
};
default:
return state;
}
};
const LOGIN = 'LOGIN';
const LOGOUT = 'LOGOUT';
const authReducer = (state = {authenticated: false}, action) => {
switch(action.type) {
case LOGIN:
return {
authenticated: true
}
case LOGOUT:
return {
authenticated: false
}
default:
return state;
}
};
// Define the root reducer here
const rootReducer = Redux.combineReducers({
count: counterReducer,
auth: authReducer
});
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36 Edg/117.0.2045.47
Challenge: Redux - Combine Multiple Reducers
Link to the challenge: