-
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
List: make allowedBlocks setting a constant #44011
Conversation
Size Change: +13 B (0%) Total Size: 1.25 MB
ℹ️ View Unchanged
|
I thought this was resolved in #30311. But I think it's still a good practice to pass |
Hm, yes, I wonder if that's still working. |
It does improve a bit some perf metrics for the post editor (I guess that's where we use the large-post data): Left is this branch, right is trunk, see: |
@ellatrix, I did a quick test for the memoization method introduced in #30311, and it should be working correctly. Here's a CodeSandbox if anyone is interested - https://codesandbox.io/s/memoize-setting-in-child-0t547m |
@@ -128,7 +129,7 @@ export default function Edit( { attributes, setAttributes, clientId, style } ) { | |||
...( Platform.isNative && { style } ), | |||
} ); | |||
const innerBlocksProps = useInnerBlocksProps( blockProps, { | |||
allowedBlocks: [ 'core/list-item' ], | |||
allowedBlocks: ALLOWED_BLOCKS, |
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.
The whole object passed as the second arg of this useInnerBlocksProps()
call could be a constant, couldn't it?
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 could be, but I think we shallow compare it anyway, so there would be no point.
What?
Settings are shallowly checked, so passing a new array on every render will cause the settings to be updated on every render.
Ideally this should be taken care of under the hood so blocks don't have to worry about this.
Why?
How?
Testing Instructions
Screenshots or screencast