From cd7d65b6ed0a1fda23a1c67581ebffadd86f9614 Mon Sep 17 00:00:00 2001 From: Mitchell Austin Date: Sun, 20 Aug 2023 14:47:00 -0700 Subject: [PATCH] =?UTF-8?q?Fix=20the=20`useSelect`=20warning=20of=20the=20?= =?UTF-8?q?=E2=80=9CCopy=20all=20blocks=E2=80=9D=20menu=20item?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/plugins/copy-content-menu-item/index.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/edit-post/src/plugins/copy-content-menu-item/index.js b/packages/edit-post/src/plugins/copy-content-menu-item/index.js index 3cbaf8697cd36..6600fc79d9c27 100644 --- a/packages/edit-post/src/plugins/copy-content-menu-item/index.js +++ b/packages/edit-post/src/plugins/copy-content-menu-item/index.js @@ -2,7 +2,7 @@ * WordPress dependencies */ import { MenuItem } from '@wordpress/components'; -import { useSelect, useDispatch } from '@wordpress/data'; +import { select, useDispatch } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { useCopyToClipboard } from '@wordpress/compose'; import { store as noticesStore } from '@wordpress/notices'; @@ -10,11 +10,6 @@ import { store as editorStore } from '@wordpress/editor'; export default function CopyContentMenuItem() { const { createNotice } = useDispatch( noticesStore ); - const getText = useSelect( - ( select ) => () => - select( editorStore ).getEditedPostAttribute( 'content' ), - [] - ); function onSuccess() { createNotice( 'info', __( 'All content copied.' ), { @@ -23,7 +18,10 @@ export default function CopyContentMenuItem() { } ); } - const ref = useCopyToClipboard( getText, onSuccess ); + const ref = useCopyToClipboard( + () => select( editorStore ).getEditedPostAttribute( 'content' ), + onSuccess + ); return { __( 'Copy all blocks' ) }; }