-
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
Editor: Use hooks instead of HoC in BlockManager
#65349
Conversation
showBlockTypes( blockNames ); | ||
} | ||
|
||
const filteredBlockTypes = useMemo( () => { |
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.
I have taken this comment into account and cached the results, but is this a good idea?
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.
The original comment concerns returning a new array reference from the mapSelect
callback. This would result in a rerender every time the block store is updated and a warning from useSelect
in dev mode.
It should be okay to leave it without memoization. But don't have a strong opinion here.
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.
I see. Just to be safe, I would like to remove useMemo
and then merge.
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.
Sounds good 👍
Size Change: -35 B (0%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
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. |
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.
Thank you, @t-hamano!
The refactoring looks good to me and everything works as before ✅
What?
This PR refactors the
BlockManager
component to use hooks.Why?
Optimization. This is also preparation for moving forward with #62703.
Testing Instructions
Open the Preferences modal and go to the section "Manage block visibility".
Note: It should be easier to confirm if you test it after opening the block inserter.
Screenshots or screencast
90749cade18aa93f28638e09542c2f5a.mp4