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

Pass own props to areStatesEqual #907

Closed
gawhyte opened this issue Mar 26, 2018 · 1 comment
Closed

Pass own props to areStatesEqual #907

gawhyte opened this issue Mar 26, 2018 · 1 comment

Comments

@gawhyte
Copy link

gawhyte commented Mar 26, 2018

I have often found myself wishing that a component's own props were available in the areStatesEqual method. I usually use an immutable.js store and convert to plain JS objects while mapping (which can potentially be expensive) and use areStatesEqual to prevent mapping unnecessarily. I am also sometimes using a property of the component to slice off a subsection of the state which leads me to wish I could sometimes do something like this:

connect(
    (state, props) => state[props.context].toJS(),
    null,
    null,
    {
      areStatesEqual: (nextState, prevState, nextProps, prevProps) => nextState[nextProps.context].equals(prevState[prevProps.context]),
    }
)

Does anybody else encounter/wish for this? Is there a philosophical reason this shouldn't be done? Looking at the code it appears it would be trivial to make this change. I thought it best I should check before opening a pull request.

@timdorr
Copy link
Member

timdorr commented Mar 26, 2018

Dupe of #781

@timdorr timdorr closed this as completed Mar 26, 2018
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

No branches or pull requests

2 participants