-
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 Editor: Optimize useAvailableAlignments
performance
#46655
Conversation
Size Change: +16 B (0%) Total Size: 1.32 MB
ℹ️ View Unchanged
|
@tyxla, what theme were you using to test this scenario? |
Twenty Twenty-Two v1.3, testing in the post editor. |
e855c83
to
14687c0
Compare
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, @tyxla!
This is a straightforward optimization, and I couldn't spot any regressions.
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.
Good catch, thank you!
What?
This PR optimizes the performance of the
useAvailableAlignments
hook by returning the same array instead of a new one whenever we have no available alignments.Why?
When we render on a theme that supports no alignments, we'll trigger additional rerenders because we return a new array every time.
How?
This PR alters the
useAvailableAlignments
hook to always return the same empty array in that scenario.Testing Instructions
none
alignment option #35822 still work.