-
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
Infinite loops may occur when using useInnerBlocksProps from WordPress 5.7. #30408
Comments
Thanks for reporting this @ddryo. This was also noticed on some core blocks and as @torounit mentions, has been fixed in #30311. That should be available in v10.4. The problem is caused by a new array for If you'd like to fix the problem in your block before, you can make a similar change to the one here - https://github.com/WordPress/gutenberg/pull/30274/files |
After updating to version 5.7, custom blocks using
__experimentalUseInnerBlocksProps
now get the "Maximum update depth exceeded" error.These errors seems to occur only under some special conditions. I would like to report here the conditions that I have confirmed and how to avoid them.
How to reproduce the error
I have created a plugin that adds a block that meets the conditions that cause an error, so please use that.
▼ Plugin that can reproduce the error
https://github.com/ddryo/Error-Reproducer/tree/main/reproduce-use-innner-blocks-props-error
Get ready
reproduce-use-innner-blocks-props-error
folder from the link above.npm i
andnpm build
.wp-env start
.Error 1:
But, saving the post and refreshing the screen will fix the problem.
For some reason, an error occurs only when inserting for the first time.
Error occurrence condition
apiVersion
is2
.__experimentalUseInnerBlocksProps
.__experimentalUseInnerBlocksProps
is used in its child blocks.template
option is specified in the child block.useSelect
is used in the parent block, and the data of the inner blocks is acquired byselect('core/block-editor').getBlocks()
.How to avoid the error
template
option from the child block.getBlocks()
method withuseSelect
and executegetBlocks()
inside the onChange process of the block controller.Error 2:
Error occurrence condition
apiVersion
is2
.__experimentalUseInnerBlocksProps
.__experimentalUseInnerBlocksProps
is used in its child blocks.allowedBlocks
option is specified in the child block, and specify the array directly in theallowedBlocks
option.How to avoid the error
allowedBlocks
with a variable.For example,
to
(Note:
ALLOWED_BLOCKS
is defined outside ofregisterBlockType()
.)WordPress information
Device information
The text was updated successfully, but these errors were encountered: