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

Reuse latest selected state on selector re-run (#1654) #1660

Merged
merged 2 commits into from
Mar 22, 2021

Conversation

otakustay
Copy link
Contributor

I'm not sure if it is a simple fix or a potential breaking change, but reuse latest selected state is quite important in preventing components from re-render frequently

@netlify
Copy link

netlify bot commented Nov 7, 2020

Deploy preview for react-redux-docs ready!

Built with commit b53d184

https://deploy-preview-1660--react-redux-docs.netlify.app

count: count + 1,
}))

const alwaysEqual = () => true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this also maintain the latest state if the equalityFn is defined within the component or inline?

Copy link
Contributor

@nightpool nightpool Dec 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes—it only cares what the equalityFn returns, not what its identity is. However, having a non-pure equalityFn (i.e., one that closes over variables from its surrounding components) could have very surprising results.

src/hooks/useSelector.js Outdated Show resolved Hide resolved
@markerikson
Copy link
Contributor

Seems reasonable, I think.

@brianathere
Copy link

I'm encountering the same issue, and this would be a nice fix. Is there something I can do to help with merging this PR?

@markerikson
Copy link
Contributor

Yeah, let's do this.

@markerikson markerikson merged commit 65b4a16 into reduxjs:master Mar 22, 2021
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.

6 participants