-
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
Navigation Block: Avoid creating a new array/object on every render #30374
Conversation
This PR's not strictly necessary now that #30311 is merged, but it is a very minor optimisation. |
Size Change: -2 B (0%) Total Size: 1.42 MB
ℹ️ View Unchanged
|
👍 Optimisation + clearer code |
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.
It's is good practice to keep this out of component render functions, but we should assume that block authors are not doing this. I wonder if we should leave it as is to better expose problems? I don't mind either way.
I was wondering about tests for it. It's easy enough to add a block via a plugin that creates a new array on every render, but not sure how we'd detect the problem, as it doesn't seem like a completely consistent behaviour. |
Description
Same as #30274, the navigation block is also creating new arrays and objects for inner blocks props on every render.
Types of changes
Task
Checklist:
*.native.js
files for terms that need renaming or removal).