-
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
Avoid rerenders of the entire BlockInspector when block attributes change #21990
Conversation
Size Change: +2 B (0%) Total Size: 819 kB
ℹ️ View Unchanged
|
@youknowriad This PR combined with #21973 fixes the performance issue even without the |
@adamziel Thanks for your work, these improvements are great. I'll take a look at this PR a bit later but keeping "memo" is totally fine. Good point about BlockStyles being expensive, that said, I wonder if the expensive component is actually BlockPreview used by BlockStyles and not BlockStyles itself so I wonder whether we should move the "memo" there. |
Thank you!
@youknowriad Good point! I'll merge #21973 and spin a new PR for that. |
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 didn't really test the performance impact here but the changes look good regardless.
Awesome, thank you so much! Also, that new PR to |
Description
BlockInspector
usesuseSlot( InspectorAdvancedControls.slotName )
. Whenever any fill is updated, the entire BlockInspector is re-rendered. This causes performance problems like the ones described in #21973. This PR extracts theInspectorAdvancedControls
fills into a sub-component to avoid re-rendering the entire inspector.How has this been tested?
For some reason, my react dev tools fail to capture the re-render of
BlockInspector
. This makes testing a little bit harder, but not impossible:console.log("BlockInspector rendered")
as a first statement in theBlockInspector
componentBlockInspector rendered
was logged about 10 times.BlockInspector rendered
was not logged in response to changing the backgroundTypes of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: