Combine Multiple Reducers!

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/

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.

1 Like

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

1 Like

The rootReducer() is not function ?
If I write

`const rootReducer = () => Redux.combineReducers({

  auth: authenticationReducer,
  notes: notesReducer

});
`
why doesn’t it work ?