-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Pattern block: avoid fetching all reusable blocks on mount #60310
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +138 B (0%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
@jsnajdr Does this look ok to you? |
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.
Good idea, just pointed out some doubts about memoization.
return mapUserPattern( | ||
block, | ||
state.settings.__experimentalUserPatternCategories | ||
); |
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.
This will return a new instance on each call, with the same state and params. Not a good value to use as dependant of getParsedPattern
.
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.
Oh, you're right, I'll fix it
10 | ||
); | ||
const block = unlock( select( STORE_NAME ) ) | ||
.getReusableBlocks() |
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.
Please remind me, why are all the selectors in this patch registry selectors, when they all select from the block-editor
store? Why can't this unlock( select() ).getReusableBlocks()
be a straighforward getReusableBlocks
?
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.
Because it's a resolving selector :)
fcc66a6
to
7dc6fd9
Compare
What?
Inside the Pattern block, we use
__experimentalGetParsedPattern
to get the pattern blocks. This selector fetches all reusable blocks, even though we can tell from the slug if we need those or not.Why?
Simply mounting pattern blocks in the editor shouldn't trigger all reusable blocks to be fetched from the server.
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast