Skip to content

Add ownProps to mapStateToProps and mapDispatchToProps as second parameter #52

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

Closed
gaearon opened this issue Aug 11, 2015 · 8 comments
Closed

Comments

@gaearon
Copy link
Contributor

gaearon commented Aug 11, 2015

It should only be passed if fn.length > 1 as per #36 (comment).

If you want to make a PR, please write here so we don't duplicate effort.

@gaearon
Copy link
Contributor Author

gaearon commented Aug 11, 2015

Important note: if mapDispatchToProps.length < 2, mapDispatchToProps should not be called on prop change.

Similarly, if mapStateToProps.length < 2 or mergeProps.length < 3, componentWillReceiveProps should not result in their recalculation, respectively.

@gaearon
Copy link
Contributor Author

gaearon commented Aug 11, 2015

cc @jhollingworth, @danharper, @ForbesLindesay who wanted to make this happen

@jhollingworth
Copy link
Contributor

Happy to implement this if no one else is

@gaearon
Copy link
Contributor Author

gaearon commented Aug 12, 2015

Feel free to!

ide added a commit to ide/react-redux that referenced this issue Aug 14, 2015
Addresses part of reduxjs#52 by passing the parent props into mapStateWithProps.
ide added a commit to ide/react-redux that referenced this issue Aug 14, 2015
Addresses part of reduxjs#52 by passing the parent props into mapStateWithProps.
jhollingworth added a commit that referenced this issue Aug 16, 2015
ide added a commit to ide/react-redux that referenced this issue Aug 17, 2015
Addresses part of reduxjs#52 by passing the parent props into mapStateWithProps.
@PSpSynedra
Copy link
Contributor

@Gaeron What is the current state of this issue?
We were just updating to redux 1.0.x and have serious problems with props not being available to mapStateToProps. The reason is that we pass memoized selector functions via props that select the desired childProperties from the state.
As a workaround we could select the whole state and thus have it passed to the mergeProps callback. The problem using this workaround is, that the potentionally expensive mergeProps becomes the mapStateToProps and is callled much to often (the recomputeState is actually called for every state change in the redux store, no matter what part of the state was influenced by the change).

@imevro
Copy link

imevro commented Aug 17, 2015

@PSpSynedra #59 (comment)

@PSpSynedra
Copy link
Contributor

@theaqua, Yeah I just saw it :-) Looking forward to it already.

@gaearon
Copy link
Contributor Author

gaearon commented Aug 17, 2015

Released in 0.9.0, please verify.

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

No branches or pull requests

4 participants