Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is nested combineReducers a bad or good idea? #738

Closed
dmitry-zaets opened this issue Sep 16, 2015 · 3 comments
Closed

Is nested combineReducers a bad or good idea? #738

dmitry-zaets opened this issue Sep 16, 2015 · 3 comments
Labels

Comments

@dmitry-zaets
Copy link
Contributor

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
  })
});
@gaearon
Copy link
Contributor

gaearon commented Sep 16, 2015

Sure, it's a fine idea.

@justinlazaro-ubidy
Copy link

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.

@markerikson
Copy link
Contributor

@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!

@reduxjs reduxjs locked as resolved and limited conversation to collaborators Jan 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants