From 424008d9dee027e5c8494e1a028f28f98d6d84a5 Mon Sep 17 00:00:00 2001 From: Jarda Snajdr Date: Mon, 24 Oct 2022 10:12:59 +0200 Subject: [PATCH] Navigation block: return undefined from useEffect --- .../src/navigation/edit/index.js | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/packages/block-library/src/navigation/edit/index.js b/packages/block-library/src/navigation/edit/index.js index 8f26e1c57cc3a..918b609f92a0e 100644 --- a/packages/block-library/src/navigation/edit/index.js +++ b/packages/block-library/src/navigation/edit/index.js @@ -272,7 +272,7 @@ function Navigation( { fallbackNavigationMenus?.length > 0 || classicMenus?.length !== 1 ) { - return false; + return; } // If there's non fallback navigation menus and @@ -481,24 +481,22 @@ function Navigation( { // Prompt the user to publish the menu they have set as a draft const isDraftNavigationMenu = navigationMenu?.status === 'draft'; - useEffect( async () => { + useEffect( () => { hideMenuAutoPublishDraftNotice(); - if ( ! isDraftNavigationMenu ) return; - try { - await editEntityRecord( - 'postType', - 'wp_navigation', - navigationMenu?.id, - { - status: 'publish', - }, - { throwOnError: true } - ); - } catch { + if ( ! isDraftNavigationMenu ) { + return; + } + editEntityRecord( + 'postType', + 'wp_navigation', + navigationMenu?.id, + { status: 'publish' }, + { throwOnError: true } + ).catch( () => { showMenuAutoPublishDraftNotice( __( 'Error occurred while publishing the navigation menu.' ) ); - } + } ); }, [ isDraftNavigationMenu, navigationMenu ] ); const stylingInspectorControls = (