Data: Respect changing props from withDispatch's mapDispatchToProps #11870
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related (alternative to): #11866
This pull request seeks to update
withDispatchto resolve an issue where if a different set of keys is returned frommapDispatchToProps, they are not immediately made available to the underlying component.Implementation notes:
This approach abandons the prior implementation of "proxy props", which were introduced as a means to limit React's reconciliation process, since it's assumed that
mapDispatchToPropswill always define new function references in its return object. While the previous proxying avoided this behavior, it did so at the expense of needing to iterate keys of the return value ofmapDispatchToProps, and of needing to callmapDispatchToPropsonce more at the time of the actual dispatch to account for any outer-scope variable definitions referenced by the dispatch callback. In fairness, the latter of these is a more minor point, since component dispatches very infrequently relative to rendering updates.In all, there is likely little practical impact here so far as performance is concerned, but it does fix the previously-broken implication that
mapDispatchToPropsmay return a different result in response to receivedownProps. The approach in #11866 improves performance, but makes clear there is no support for changing the return shape ofmapDispatchToProps.Testing instructions:
Ensure tests pass: