Skip to content

Commit

Permalink
Move map outside of useSelect
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed Sep 5, 2024
1 parent 9382b2a commit ac443f5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/editor/src/components/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,7 @@ export const ExperimentalEditorProvider = withRegistryProvider(
isReady: __unstableIsEditorReady(),
mode: getRenderingMode(),
selection: getEditorSelection(),
postTypes:
getPostTypes( { per_page: -1 } )?.map(
( entity ) => entity.slug
) || [],
postTypes: getPostTypes( { per_page: -1 } ),
};
}, [] );
const shouldRenderTemplate = !! template && mode !== 'post-only';
Expand All @@ -199,8 +196,13 @@ export const ExperimentalEditorProvider = withRegistryProvider(
break;
case 'single':
// Infer the post type from the slug.
const postTypesSlugs =
postTypes?.map( ( entity ) => entity.slug ) ||
[];
const match = post.slug.match(
`^single-(${ postTypes.join( '|' ) })(?:-.+)?$`
`^single-(${ postTypesSlugs.join(
'|'
) })(?:-.+)?$`
);
if ( match ) {
postContext.postType = match[ 1 ];
Expand Down

0 comments on commit ac443f5

Please sign in to comment.