`Combine Multiple Reducers`

`Combine Multiple Reducers`
0

#1

Tell us what’s happening:

I believe this is so easy but I don;t know why I don’t understand it.
Can you explain where is my wrong?

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,auth);



};


// define the root reducer here

const store = Redux.createStore(rootReducer);

Your browser information:

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

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


#2

Check the official documentation:
https://redux.js.org/api/combinereducers

The root reducer is the Redux combineReducer which recieves an object containing your app reducers.

You tried to make your root reducer like the rest of the reducers, but it isn’t actually a reducer, but a combination of your apps reducers.

It should look something like this:

const rootReducer = Redux.combineReducers({
    auth: authReducer,
    counter: counterReducer,
    ......
});