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

Should combineReducers return the same object if nothing changes? #853

Closed
aaronjensen opened this issue Oct 6, 2015 · 5 comments
Closed

Comments

@aaronjensen
Copy link
Contributor

Right now, the reducer returned by combineReducers returns a new object regardless of whether or not the reducers it is combining make any changes. This means breaking reference equal every action, which limits its usefulness when using nested combinations unless you always select all the way down to the piece of state that maintains reference equality integrity. It'd be a little bit more slow to introduce an equality check, after the mapValues but it seems like it'd be better, yeah?

@gaearon
Copy link
Contributor

gaearon commented Oct 6, 2015

Let's add the check. Something like hasChanged = false which gets set to true if newState[key] !== state[key]. If !hasChanged, we will return the previous state.

@georgebonnr
Copy link

💯 Went through a painful process figuring out why disparate parts of my app were re-rendering. Was about to write my own function when I figured this out, but glad I can update instead. 👍

@Tomassito
Copy link

@aaronjensen Can you help me understand the issue here? You're normally interested in only a part of the state that you're combining together. You'd have to have a dependency on the whole combined chunk in order to run into trouble, right? Have you got such usecase really?

@aaronjensen
Copy link
Contributor Author

I don’t use redux anymore. This issue is 6 years old.

@aaronjensen
Copy link
Contributor Author

I imagine I did have a use case at the time or I would not have opened an issue and submitted a patch.

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

No branches or pull requests

4 participants