Pattern block: avoid fetching all reusable blocks on mount#60310
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? |
jsnajdr
left a comment
There was a problem hiding this comment.
Good idea, just pointed out some doubts about memoization.
| return mapUserPattern( | ||
| block, | ||
| state.settings.__experimentalUserPatternCategories | ||
| ); |
There was a problem hiding this comment.
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.
Oh, you're right, I'll fix it
| 10 | ||
| ); | ||
| const block = unlock( select( STORE_NAME ) ) | ||
| .getReusableBlocks() |
There was a problem hiding this comment.
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.
Because it's a resolving selector :)
fcc66a6 to
7dc6fd9
Compare
What?
Inside the Pattern block, we use
__experimentalGetParsedPatternto 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