From b611401c77b8b132e7d906cfb5f1c6a3ef49f33d Mon Sep 17 00:00:00 2001 From: Haz Date: Fri, 19 Jun 2020 12:08:04 -0300 Subject: [PATCH] Refactor header toolbar items to use @wordpress/data hooks --- .../src/components/editor-history/redo.js | 24 +++++---------- .../src/components/editor-history/undo.js | 24 +++++---------- .../src/components/table-of-contents/index.js | 24 +++++---------- .../src/components/table-of-contents/panel.js | 29 +++++++++---------- 4 files changed, 36 insertions(+), 65 deletions(-) diff --git a/packages/editor/src/components/editor-history/redo.js b/packages/editor/src/components/editor-history/redo.js index 2e359963bd172..7bfd25a81ba71 100644 --- a/packages/editor/src/components/editor-history/redo.js +++ b/packages/editor/src/components/editor-history/redo.js @@ -3,17 +3,20 @@ */ import { __ } from '@wordpress/i18n'; import { Button } from '@wordpress/components'; -import { withSelect, withDispatch } from '@wordpress/data'; -import { compose } from '@wordpress/compose'; +import { useSelect, useDispatch } from '@wordpress/data'; import { displayShortcut } from '@wordpress/keycodes'; import { redo as redoIcon } from '@wordpress/icons'; import { forwardRef } from '@wordpress/element'; -function EditorHistoryRedo( { hasRedo, redo, innerRef, ...props } ) { +function EditorHistoryRedo( props, ref ) { + const hasRedo = useSelect( ( select ) => + select( 'core/editor' ).hasEditorRedo() + ); + const { redo } = useDispatch( 'core/editor' ); return (