From 09b0cdcef7a358db474569f31c53cd02d79d1d93 Mon Sep 17 00:00:00 2001 From: Matt Sherman Date: Fri, 13 Oct 2023 00:19:11 -0400 Subject: [PATCH] Memoize block context --- .../src/components/block-editor/block-editor.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/js/product-editor/src/components/block-editor/block-editor.tsx b/packages/js/product-editor/src/components/block-editor/block-editor.tsx index 096db382af8..fbe6c3af1f4 100644 --- a/packages/js/product-editor/src/components/block-editor/block-editor.tsx +++ b/packages/js/product-editor/src/components/block-editor/block-editor.tsx @@ -54,6 +54,13 @@ export function BlockEditor( { }: BlockEditorProps ) { useConfirmUnsavedProductChanges( productType ); + const blockContext = useMemo( () => { + return { + ...context, + productType, + }; + }, [ context, productType ] ); + const canUserCreateMedia = useSelect( ( select: typeof WPSelect ) => { const { canUser } = select( 'core' ); return canUser( 'create', 'media', '' ) !== false; @@ -106,7 +113,7 @@ export function BlockEditor( { return (
- +