Skip to content

Commit

Permalink
Update: Avoid two useSelect calls on PostActions.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Apr 15, 2024
1 parent 06b3537 commit 1b70902
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions packages/editor/src/components/post-actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,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(
Expand Down

0 comments on commit 1b70902

Please sign in to comment.