Framework: Replace is-equal-shallow with shallowequal #5616
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.
This pull request seeks to resolve a performance regression caused by a bailout condition in our chosen shallow-equality library
is-equal-shallow
:https://github.com/jonschlinkert/is-equal-shallow/blob/592a07eb802e8043493a983eee901e2b56b4b05c/index.js#L19-L20
Specifically, our data
withSelect
higher-order component relies on reference equality check to prevent unnecessary re-renders.gutenberg/data/index.js
Lines 214 to 218 in 409ac98
Since the above logic will abort (and flag as unequal) if it encounters a non-primitive type, this optimization is very frequently bypassed.
The changes here swap to an alternate implementation which does not include such a bailout.
See implementation: https://github.com/dashed/shallowequal/blob/master/index.js
Testing instructions:
With React DevTools, verify that updating a block should only impact the block itself, not re-rendering large amounts of the application.