Skip to content

Commit

Permalink
Block Library: Post Title: Ensure post entity is fetched
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Apr 10, 2020
1 parent 9b96b65 commit 7de9e83
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/block-library/src/post-title/edit.js
Expand Up @@ -5,13 +5,19 @@ import { useSelect } from '@wordpress/data';

export default function PostTitleEdit( { context } ) {
const { postType, postId } = context;
const post = useSelect(
( select ) =>

// The unused `getEntityRecord` is necessary to trigger the default resolver
// behavior to fetch the post if not already known. Ideally this is built-in
// to `getEditedEntityRecord`, which derives using `getEntityRecord`.
const [ post ] = useSelect(
( select ) => [
select( 'core' ).getEditedEntityRecord(
'postType',
postType,
postId
),
select( 'core' ).getEntityRecord( 'postType', postType, postId ),
],
[ 'postType', 'postId' ]
);

Expand Down

0 comments on commit 7de9e83

Please sign in to comment.