Combine Multiple Reducers!

Combine Multiple Reducers!
0.0 0

#1

Tell us what’s happening:
Hello friends, please help me! Im not understand how i must assign auth and count keys to Redux.combineReducers

Your code so far


const 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;
  }
};

const rootReducer  = (state, action) =>
{
Redux.combineReducers({
  count: counterReducer,
  auth: authReducer
});
};

const store = Redux.createStore(rootReducer);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/redux/combine-multiple-reducers/


#2

You need to follow the example of their rootReducer method like shown in the instructions:

const rootReducer = Redux.combineReducers({
  auth: authenticationReducer,
  notes: notesReducer
});

You need to remove (state, action), ect. You’re sorta close with your answer.


#3

Thank you friend, i mixed up((((!