Skip to content

Commit

Permalink
Fetch statuses from entity
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Oct 5, 2023
1 parent 16cd768 commit 1347cec
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/edit-site/src/components/page-pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
__experimentalVStack as VStack,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { useEntityRecords } from '@wordpress/core-data';
import { useSelect } from '@wordpress/data';
import { useEntityRecords, store as coreStore } from '@wordpress/core-data';
import { decodeEntities } from '@wordpress/html-entities';
import { useState, useEffect, useMemo } from '@wordpress/element';

Expand All @@ -32,11 +33,10 @@ export default function PagePages() {
pageSize: PAGE_SIZE_VALUES[ 0 ],
} );
// Request post statuses to get the proper labels.
const [ postStatuses, setPostStatuses ] = useState( EMPTY_ARRAY );
useEffect( () => {
apiFetch( {
path: '/wp/v2/statuses',
} ).then( setPostStatuses );
// TODO: we should probably use `useEntityRecords` here.
const postStatuses = useSelect( ( select ) => {
const { getPostStatuses } = select( coreStore );
return getPostStatuses();
}, [] );

// TODO: probably memo other objects passed as state(ex:https://tanstack.com/table/v8/docs/examples/react/pagination-controlled).
Expand Down

0 comments on commit 1347cec

Please sign in to comment.