Memoize block context
This commit is contained in:
parent
86a0a15588
commit
09b0cdcef7
|
@ -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 (
|
||||
<div className="woocommerce-product-block-editor">
|
||||
<BlockContextProvider value={ { ...context, productType } }>
|
||||
<BlockContextProvider value={ blockContext }>
|
||||
<BlockEditorProvider
|
||||
value={ blocks }
|
||||
onInput={ onInput }
|
||||
|
|
Loading…
Reference in New Issue