From 6683673270e4781e74dced0a362e1b6b34350384 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 --- .../block-editor/src/components/block-navigation/toolbar.js | 5 +++-- .../src/components/menu-editor/navigation-structure-panel.js | 5 +++-- 2 files changed, 6 insertions(+), 4 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 a464bfcd4e7eac..530ed8aa1546e0 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,8 +10,9 @@ import { useDispatch, useSelect } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; export default function NavigationStructurePanel( { blocks } ) { - const selectedBlockClientIds = useSelect( ( select ) => - select( 'core/block-editor' ).getSelectedBlockClientIds() + const blockClientIds = useSelect( + ( select ) => select( 'core/block-editor' ).getSelectedBlockClientIds(), + [] ); const { selectBlock } = useDispatch( 'core/block-editor' );