-
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
Block Editor: Memoize the createPageEntity callback #54580
Block Editor: Memoize the createPageEntity callback #54580
Conversation
…firing on every keystroke
Size Change: +13 B (0%) Total Size: 1.62 MB
ℹ️ View Unchanged
|
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.
LGTM 👍 .
Why didn't the linter catch this? 🤔
Good question - my VS Code linter highlighted the issue. |
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.
A bit late now but this tested well for me also.
FWIW, in addition to the linter displaying the warning in VS Code, my LSP diagnostics in Neovim also flagged it.
Thanks for the quick fix 👍 |
What?
Memoizes the createPageEntity callback in the useBlockEditorSettings hook.
Why?
Because a new function is generated with every call currently the useBlockEditorSettings useMemo return hook is being rerun with every keystroke in the block editor.
How?
Wraps the function in a
useCallback
.Testing Instructions
Create page
option that appears in dropdownScreenshots or screencast
newpage.mp4