From 1f6a58a3756c76818356373df936efd813907be7 Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Mon, 15 Apr 2024 17:23:01 +0100 Subject: [PATCH] Update: Avoid two useSelect calls on PostActions. --- .../editor/src/components/post-actions/index.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/packages/editor/src/components/post-actions/index.js b/packages/editor/src/components/post-actions/index.js index 379231b0a9dff0..f32c90dd156c19 100644 --- a/packages/editor/src/components/post-actions/index.js +++ b/packages/editor/src/components/post-actions/index.js @@ -2,7 +2,6 @@ * WordPress dependencies */ import { useSelect } from '@wordpress/data'; -import { store as coreStore } from '@wordpress/core-data'; import { useMemo, useState, Fragment, Children } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { @@ -41,24 +40,17 @@ const POST_ACTIONS_WHILE_EDITING = [ ]; export default function PostActions( { onActionPerformed } ) { - const { postType, postId } = useSelect( ( select ) => { - const { getCurrentPostType, getCurrentPostId } = select( editorStore ); + const { postType, item } = useSelect( ( select ) => { + const { getCurrentPostType, getCurrentPost } = select( editorStore ); return { postType: getCurrentPostType(), - postId: getCurrentPostId(), + item: getCurrentPost(), }; } ); const actions = usePostActions( onActionPerformed, POST_ACTIONS_WHILE_EDITING ); - const item = useSelect( - ( select ) => { - const { getEditedEntityRecord } = select( coreStore ); - return getEditedEntityRecord( 'postType', postType, postId ); - }, - [ postType, postId ] - ); const { primaryActions, secondaryActions } = useMemo( () => { return actions.reduce(