Skip to content

Commit

Permalink
Merge pull request reduxjs#2706 from squirrelnest/patch-1
Browse files Browse the repository at this point in the history
Clarify combineReducers documentation
  • Loading branch information
markerikson authored Nov 9, 2017
2 parents 6adc754 + 2d893c9 commit e6a15f2
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions docs/api/combineReducers.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@ As your app grows more complex, you'll want to split your [reducing function](..

The `combineReducers` helper function turns an object whose values are different reducing functions into a single reducing function you can pass to [`createStore`](createStore.md).

The resulting reducer calls every child reducer, and gathers their results into a single state object. **The shape of the state object matches the keys of the passed `reducers`**.

Consequently, the state object will look like this:
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
{
reducer1: ...
reducer2: ...
potato: {
// ... potatoes, and other state managed by the potatoReducer ...
}
tomato: {
// ... tomatoes, and other state managed by the tomatoReducer, maybe some nice sauce? ...
}
}
```

Expand Down

0 comments on commit e6a15f2

Please sign in to comment.