Redux: Is nested combineReducers a bad or good idea?

Created on 16 Sep 2015  ·  3Comments  ·  Source: reduxjs/redux

Can combineReducers be nested or it should be used once to combine all the reducers into one?
Is that a bad approach to create a tree structure of store by combining reducers on each step?

Or probably there is any other way to keep root store clean (want to avoid placing all tree leaves into root store)
Pseudocode structure example:

rootReducer = combineReducers({
  router, // redux-react-router reducer
    account: combineReducers({
      profile: combineReducers({
         info, // reducer function
         credentials // reducer function
      }),
      billing // reducer function
    }),
    // ... other combineReducers
  })
});
question

Most helpful comment

Sure, it's a fine idea.

All 3 comments

Sure, it's a fine idea.

Hi im implementin a multiple combineReducer,

// schoolReducer.js

export default combineReducers({
  company: companyReducer,
  profile: profileReducer,
});

// studentInfo.js

export default combineReducers({
  student: studentReducer,
  course: courseReducer,
});

//rootReducer.js

export default combineReducers({
  school: schoolReducer,
  student: studentInfo,
});

having an error

Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.

@justinlazaro-ubidy :
This is a bug tracker, not a support system. For usage questions, please use Stack Overflow or Reactiflux where there are a lot more people ready to help you out - you'll probably get a better answer faster. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

captbaritone picture captbaritone  ·  3Comments

elado picture elado  ·  3Comments

benoneal picture benoneal  ·  3Comments

cloudfroster picture cloudfroster  ·  3Comments

jbri7357 picture jbri7357  ·  3Comments