Skip to content

Commit

Permalink
useBlockTypesState: divide useSelect call into two (#57163)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnajdr authored and artemiomorales committed Jan 4, 2024
1 parent 328ba60 commit 59e433a
Showing 1 changed file with 9 additions and 11 deletions.
Expand Up @@ -23,20 +23,18 @@ import { store as blockEditorStore } from '../../../store';
* @return {Array} Returns the block types state. (block types, categories, collections, onSelect handler)
*/
const useBlockTypesState = ( rootClientId, onInsert ) => {
const { categories, collections, items } = useSelect(
( select ) => {
const { getInserterItems } = select( blockEditorStore );
const { getCategories, getCollections } = select( blocksStore );

return {
categories: getCategories(),
collections: getCollections(),
items: getInserterItems( rootClientId ),
};
},
const [ items ] = useSelect(
( select ) => [
select( blockEditorStore ).getInserterItems( rootClientId ),
],
[ rootClientId ]
);

const [ categories, collections ] = useSelect( ( select ) => {
const { getCategories, getCollections } = select( blocksStore );
return [ getCategories(), getCollections() ];
}, [] );

const onSelectItem = useCallback(
(
{ name, initialAttributes, innerBlocks, syncStatus, content },
Expand Down

0 comments on commit 59e433a

Please sign in to comment.