From a07718bab720e2d0ee6f44d891c3841cf1485d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ella=20van=C2=A0Durpe?= Date: Wed, 19 May 2021 19:21:45 +0300 Subject: [PATCH] Revert changes to useBlockElement --- .../components/block-list/use-block-props/use-block-refs.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/block-list/use-block-props/use-block-refs.js b/packages/block-editor/src/components/block-list/use-block-props/use-block-refs.js index 44da41fe8bf91..56e424319739e 100644 --- a/packages/block-editor/src/components/block-list/use-block-props/use-block-refs.js +++ b/packages/block-editor/src/components/block-list/use-block-props/use-block-refs.js @@ -93,7 +93,8 @@ function useBlockRef( clientId ) { */ function useBlockElement( clientId ) { const { callbacks } = useContext( BlockRefs ); - const [ element, setElement ] = useState( useBlockRef( clientId ).current ); + const ref = useBlockRef( clientId ); + const [ element, setElement ] = useState( null ); useLayoutEffect( () => { if ( ! clientId ) { @@ -106,7 +107,7 @@ function useBlockElement( clientId ) { }; }, [ clientId ] ); - return element; + return ref.current || element; } export { useBlockRef as __unstableUseBlockRef };