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

explain a little more what a single reducer in combination is #399

Closed

Conversation

constb
Copy link
Contributor

@constb constb commented Aug 5, 2015

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 use combineReducers things are different. Maybe docs could be a bit more explicit about that.

@@ -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`.
Copy link
Contributor

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.

@ms88privat
Copy link

I was surprised too. It is good, but it should be in the docs

@gaearon
Copy link
Contributor

gaearon commented Aug 14, 2015

Thanks. This is on my list to revisit. I added quite a bit about it into reducers doc.
I'm closing because:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants