Class 31 Combining Reducers - Alwynblake/seattle-javascript-401n12 GitHub Wiki
https://redux.js.org/api/combinereducers
-
As your app grows more complex, you'll want to split your reducing function into separate functions, each managing independent parts of the state.
-
The combineReducers helper function turns an object whose values are different reducing functions into a single reducing function you can pass to createStore.
-
The resulting reducer calls every child reducer, and gathers their results into a single state object. The state produced by combineReducers() namespaces the states of each reducer under their keys as passed to combineReducers()
-
Example:
- rootReducer = combineReducers({potato: potatoReducer, tomato: tomatoReducer})
- // This would produce the following state object
- {
- potato: {
- // ... potatoes, and other state managed by the potatoReducer ...
- },
- tomato: {
// ... tomatoes, and other state managed by the tomatoReducer, maybe some nice sauce? ...- }
- }