-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
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
explain a little more what a single reducer in combination is #399
explain a little more what a single reducer in combination is #399
Conversation
@@ -7,6 +7,8 @@ reducing function you can pass to [`createStore`](createStore.md). | |||
|
|||
The resulting reducer calls every child reducer, and gather their results into a single state object. The shape of the state object matches the keys of the passed `reducers`. | |||
|
|||
Reducer function names are important. Don't be confused by the fact that reducer parameter is named `state`. *Single reducer in the combination does not update compete state of the store.* Its name is the key of the value in the store object it gets and updates. For example, reducer named `todos` receives and changes only `state.todos`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say it's not exactly function names but keys in object you pass to combineReducers. They match function names when you use export syntax.
I was surprised too. It is good, but it should be in the docs |
Thanks. This is on my list to revisit. I added quite a bit about it into reducers doc.
|
I don't know if its my bad luck, but coming from facebook flux and seeing that every reducer in examples have parameter
state
, I assumed that every reducer manipulates complete state of the application. It took me quite a few hours before I found out that when you usecombineReducers
things are different. Maybe docs could be a bit more explicit about that.