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

arePropsEqualFuncWrapper #254

Merged
merged 6 commits into from
Jul 16, 2024
Merged

arePropsEqualFuncWrapper #254

merged 6 commits into from
Jul 16, 2024

Conversation

noacoWix
Copy link
Contributor

@noacoWix noacoWix commented Jul 14, 2024

Problem Description

In Redux, the calculation of the mergedProps depends on determining whether ownProps have changed. If ownProps change while shouldComponentUpdate is blocking the recalculation of mergedProps, a subsequent state update or propagation of seemingly unchanged ownProps (which appear the same as the last ownProps but differ from the ownProps before the blocking period) may result in incorrect mergedProps calculation. This issue arises because changes in ownProps during the blocking period are not taken into account.

Solution

This PR introduces a mechanism to detect changes in ownProps that occur while shouldComponentUpdate optimization is in effect. If such changes are detected during this blocking period, the next permitted component update will trigger a recalculation of mergedProps considering the updated ownProps.

Additional Information

For more details on how Redux calculates mergedProps and the role of areOwnPropsEqual in this process, please refer to the following link: Redux - selectorFactory.ts

@noacoWix noacoWix changed the title wrapWithShouldUpdateExperimental WIP arePropsEqualFuncWrapper WIP Jul 15, 2024
src/connectWithShell.tsx Outdated Show resolved Hide resolved
@noacoWix noacoWix requested a review from itsh01 July 15, 2024 11:26
@noacoWix noacoWix marked this pull request as ready for review July 15, 2024 18:11
@noacoWix noacoWix requested a review from shirlynwix July 15, 2024 18:11
@noacoWix noacoWix changed the title arePropsEqualFuncWrapper WIP arePropsEqualFuncWrapper Jul 15, 2024
Copy link
Collaborator

@itsh01 itsh01 left a comment

Choose a reason for hiding this comment

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

Nice fix

@noacoWix
Copy link
Contributor Author

@shirlynwix I split the test into 3 smaller tests in hope to make it more clear. Let me know what you think.

Copy link
Contributor

@shirlynwix shirlynwix left a comment

Choose a reason for hiding this comment

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

Great!

@noacoWix noacoWix merged commit 121f6cb into master Jul 16, 2024
1 check passed
@noacoWix noacoWix deleted the wrapWithShouldUpdateExperimental branch July 16, 2024 16:40
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.

3 participants