-
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
Block Directory: Optimize DownloadableBlocksPanel
#47679
Conversation
Size Change: +41 B (0%) Total Size: 1.31 MB
ℹ️ View Unchanged
|
Flaky tests detected in c148f12. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4073301940
|
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 can't really reproduce, here's what I'm seeing: Do you see any errors in the console, or any network request failures? |
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.
Tested with a different administrator user, and it works as expected.
I think I messed up my main testing account's capabilities 😅
This is a good sign, it means that the filter with |
What?
This PR improves the performance of the
DownloadableBlocksPanel
component by reducing the unnecessary updates done to the downloadable blocks (thedownloadableItems
prop). This allows us to avoid unnecessary extra updates when the parent component is re-rendered, but an update is triggered just because we return a new array with the same data.Why?
When typing into the main inserter we see a bunch of updates coming from
DownloadableBlocksPanel
with almost always the samedownloadableItems
array contents, but with a different reference.How?
We're doing a couple of optimizations:
downloadableItems
is an empty array, we make sure to always return the same empty array.downloadableItems
, since the installable blocks will always contain a new array (as it is the result ofArray.prototype.filter()
).Testing Instructions
Testing Instructions for Keyboard
None.
Screenshots or screencast
None.