From 9c030aad2cafdea575897c39586528da28772a1b Mon Sep 17 00:00:00 2001 From: Ella <4710635+ellatrix@users.noreply.github.com> Date: Sat, 27 Jan 2024 22:57:54 +0200 Subject: [PATCH] InnerBlocks: fix continuous re-rendering on inner blocks change (#58348) --- .../src/components/inner-blocks/index.js | 6 ------ .../src/components/inner-blocks/index.native.js | 12 +++--------- .../inner-blocks/use-inner-block-template-sync.js | 4 +--- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/packages/block-editor/src/components/inner-blocks/index.js b/packages/block-editor/src/components/inner-blocks/index.js index 6461d57a7e604c..4bb555d27f626c 100644 --- a/packages/block-editor/src/components/inner-blocks/index.js +++ b/packages/block-editor/src/components/inner-blocks/index.js @@ -71,7 +71,6 @@ function UncontrolledInnerBlocks( props ) { layout, name, blockType, - innerBlocks, parentLock, } = props; @@ -92,7 +91,6 @@ function UncontrolledInnerBlocks( props ) { useInnerBlockTemplateSync( clientId, - innerBlocks, template, templateLock, templateInsertUpdatesSelection @@ -193,7 +191,6 @@ export function useInnerBlocksProps( props = {}, options = {} ) { hasOverlay, name, blockType, - innerBlocks, parentLock, parentClientId, isDropZoneDisabled, @@ -208,7 +205,6 @@ export function useInnerBlocksProps( props = {}, options = {} ) { isBlockSelected, hasSelectedInnerBlock, __unstableGetEditorMode, - getBlocks, getTemplateLock, getBlockRootClientId, __unstableIsWithinBlockOverlay, @@ -234,7 +230,6 @@ export function useInnerBlocksProps( props = {}, options = {} ) { enableClickThrough, name: blockName, blockType: getBlockType( blockName ), - innerBlocks: getBlocks( clientId ), parentLock: getTemplateLock( _parentClientId ), parentClientId: _parentClientId, isDropZoneDisabled: @@ -263,7 +258,6 @@ export function useInnerBlocksProps( props = {}, options = {} ) { layout, name, blockType, - innerBlocks, parentLock, ...options, }; diff --git a/packages/block-editor/src/components/inner-blocks/index.native.js b/packages/block-editor/src/components/inner-blocks/index.native.js index 2f04854bce2fca..1398a5abd51e4b 100644 --- a/packages/block-editor/src/components/inner-blocks/index.native.js +++ b/packages/block-editor/src/components/inner-blocks/index.native.js @@ -105,17 +105,12 @@ function UncontrolledInnerBlocks( props ) { const context = useBlockContext( clientId ); - const { nestingLevel, innerBlocks, parentLock } = useSelect( + const { nestingLevel, parentLock } = useSelect( ( select ) => { - const { - getBlockParents, - getBlocks, - getTemplateLock, - getBlockRootClientId, - } = select( blockEditorStore ); + const { getBlockParents, getTemplateLock, getBlockRootClientId } = + select( blockEditorStore ); return { nestingLevel: getBlockParents( clientId )?.length, - innerBlocks: getBlocks( clientId ), parentLock: getTemplateLock( getBlockRootClientId( clientId ) ), }; }, @@ -139,7 +134,6 @@ function UncontrolledInnerBlocks( props ) { useInnerBlockTemplateSync( clientId, - innerBlocks, template, templateLock, templateInsertUpdatesSelection diff --git a/packages/block-editor/src/components/inner-blocks/use-inner-block-template-sync.js b/packages/block-editor/src/components/inner-blocks/use-inner-block-template-sync.js index 614ddad921ca4a..020b391039a01b 100644 --- a/packages/block-editor/src/components/inner-blocks/use-inner-block-template-sync.js +++ b/packages/block-editor/src/components/inner-blocks/use-inner-block-template-sync.js @@ -23,7 +23,6 @@ import { store as blockEditorStore } from '../../store'; * then we replace the inner blocks with the correct value after synchronizing it with the template. * * @param {string} clientId The block client ID. - * @param {Array} innerBlocks * @param {Object} template The template to match. * @param {string} templateLock The template lock state for the inner blocks. For * example, if the template lock is set to "all", @@ -37,7 +36,6 @@ import { store as blockEditorStore } from '../../store'; */ export default function useInnerBlockTemplateSync( clientId, - innerBlocks, template, templateLock, templateInsertUpdatesSelection @@ -112,5 +110,5 @@ export default function useInnerBlockTemplateSync( return () => { isCancelled = true; }; - }, [ innerBlocks, template, templateLock, clientId ] ); + }, [ template, templateLock, clientId ] ); }