-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Data: fix memoized createRegistrySelector #57888
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Size Change: +45 B (0%) Total Size: 1.69 MB
ℹ️ View Unchanged
|
jsnajdr
approved these changes
Jan 16, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, that was easier than I expected 😄
This was referenced Jan 19, 2024
This was referenced Jul 10, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
What?
This PR fixes
createRegistrySelector
when used in combination with a memoized selector (createSelector
).Thanks @jsnajdr for providing some tests in #57510.
The following is currently broken in trunk, it doesn't cache the result:
It does not fix binding to registry selectors to multiple registries, but this is already broken in trunk, even without
createSelector
.Why?
We have some selectors where memoization is needed. I would also like to add more registry selectors, but this flaw makes it impossible because it would mean adding unperformant selectors in important places.
gutenberg/packages/block-directory/src/store/selectors.js
Lines 56 to 65 in cdd6cec
gutenberg/packages/block-directory/src/store/selectors.js
Lines 75 to 84 in cdd6cec
gutenberg/packages/edit-site/src/store/selectors.js
Lines 244 to 261 in cdd6cec
gutenberg/packages/editor/src/store/private-selectors.js
Lines 25 to 47 in cdd6cec
gutenberg/packages/edit-widgets/src/store/selectors.js
Lines 32 to 49 in cdd6cec
And there's places where
createRegisterySelector
should be used, but currently isn't:gutenberg/packages/edit-site/src/components/page-patterns/use-patterns.js
Lines 212 to 270 in 588fc12
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast