Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Revert "Fix useForcedLayout to re-select inner blocks after we manu…
Browse files Browse the repository at this point in the history
…ally insert one (#6676)" (#7447)

This reverts commit 1564de2.
  • Loading branch information
opr authored and wavvves committed Oct 21, 2022
1 parent 9b807a4 commit 115b9b0
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions assets/js/blocks/cart-checkout-shared/use-forced-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
useRef,
useCallback,
useMemo,
useState,
} from '@wordpress/element';
import { useSelect, useDispatch } from '@wordpress/data';
import {
Expand Down Expand Up @@ -42,8 +41,6 @@ export const useForcedLayout = ( {
} ): void => {
const currentRegisteredBlocks = useRef( registeredBlocks );
const currentDefaultTemplate = useRef( defaultTemplate );
const [ forcedBlocksInserted, setForcedBlocksInserted ] =
useState< number >( 0 );

const { insertBlock, replaceInnerBlocks } =
useDispatch( 'core/block-editor' );
Expand All @@ -58,18 +55,17 @@ export const useForcedLayout = ( {
),
};
},
[ clientId, currentRegisteredBlocks.current, forcedBlocksInserted ]
[ clientId, currentRegisteredBlocks.current ]
);

const appendBlock = useCallback(
( block, position ) => {
const newBlock = createBlock( block.name );
insertBlock( newBlock, position, clientId, false );
setForcedBlocksInserted( forcedBlocksInserted + 1 );
},
// We need to skip insertBlock here due to a cache issue in wordpress.com that causes an inifinite loop, see https://github.com/Automattic/wp-calypso/issues/66092 for an expanded doc.
// eslint-disable-next-line react-hooks/exhaustive-deps
[ clientId, forcedBlocksInserted ]
[ clientId ]
);

const lockedBlockTypes = useMemo(
Expand Down

0 comments on commit 115b9b0

Please sign in to comment.