From dffd9784c3a34ff4c811511cade9d26b2fd2a829 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Mon, 6 Apr 2020 12:35:26 +0800 Subject: [PATCH] Memoize useSelect callback function Co-Authored-By: Zebulan Stanphill --- .../src/components/block-navigation/toolbar.js | 5 +++-- .../components/menu-editor/navigation-structure-panel.js | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/block-editor/src/components/block-navigation/toolbar.js b/packages/block-editor/src/components/block-navigation/toolbar.js index 35521dc964b74a..256628d40c4d3b 100644 --- a/packages/block-editor/src/components/block-navigation/toolbar.js +++ b/packages/block-editor/src/components/block-navigation/toolbar.js @@ -13,8 +13,9 @@ import BlockActions from '../block-actions'; import BlockMover from '../block-mover'; export default function BlockNavigationToolbar() { - const blockClientIds = useSelect( ( select ) => - select( 'core/block-editor' ).getSelectedBlockClientIds() + const blockClientIds = useSelect( + ( select ) => select( 'core/block-editor' ).getSelectedBlockClientIds(), + [] ); return ( diff --git a/packages/edit-navigation/src/components/menu-editor/navigation-structure-panel.js b/packages/edit-navigation/src/components/menu-editor/navigation-structure-panel.js index 99b218992aa073..a5eaf84e24fbe1 100644 --- a/packages/edit-navigation/src/components/menu-editor/navigation-structure-panel.js +++ b/packages/edit-navigation/src/components/menu-editor/navigation-structure-panel.js @@ -10,11 +10,12 @@ import { useDispatch, useSelect } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; export default function NavigationStructurePanel( { blocks, initialOpen } ) { - const selectedBlockClientIds = useSelect( ( select ) => - select( 'core/block-editor' ).getSelectedBlockClientIds() + const selectedBlockClientIds = useSelect( + ( select ) => select( 'core/block-editor' ).getSelectedBlockClientIds(), + [] ); - const { selectBlock } = useDispatch( 'core/block-editor' ); + return (