wix-incubator / repluggable

Pluggable micro frontends in React+Redux apps
MIT License
172 stars 13 forks source link

arePropsEqualFuncWrapper #254

Closed noacoWix closed 4 months ago

noacoWix commented 4 months ago

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 commented 4 months ago

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