From e80748ebfc961b3fff23cd31a7a6e12ade96438a Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Fri, 15 Apr 2022 13:13:21 +0100 Subject: [PATCH] Remove async useEffect (#40373) --- .../src/navigation/edit/unsaved-inner-blocks.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/block-library/src/navigation/edit/unsaved-inner-blocks.js b/packages/block-library/src/navigation/edit/unsaved-inner-blocks.js index 78510000dc6461..95204b33dadc7a 100644 --- a/packages/block-library/src/navigation/edit/unsaved-inner-blocks.js +++ b/packages/block-library/src/navigation/edit/unsaved-inner-blocks.js @@ -123,7 +123,7 @@ export default function UnsavedInnerBlocks( { ); // Automatically save the uncontrolled blocks. - useEffect( async () => { + useEffect( () => { // The block will be disabled when used in a BlockPreview. // In this case avoid automatic creation of a wp_navigation post. // Otherwise the user will be spammed with lots of menus! @@ -150,9 +150,10 @@ export default function UnsavedInnerBlocks( { } savingLock.current = true; - const menu = await createNavigationMenu( null, blocks ); - onSave( menu ); - savingLock.current = false; + createNavigationMenu( null, blocks ).then( ( menu ) => { + onSave( menu ); + savingLock.current = false; + } ); }, [ isDisabled, isSaving,