Use createRoot in classic product editor cases (#48834)

mothra

mothra

mothra
This commit is contained in:
RJ 2024-07-04 16:38:19 +08:00 committed by GitHub
parent 7959060850
commit e61313b33d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 6 deletions

View File

@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { render, Suspense, lazy } from '@wordpress/element';
import { createRoot, Suspense, lazy } from '@wordpress/element';
/**
* Internal dependencies
@ -20,7 +20,7 @@ if ( metaboxContainer ) {
const initialSelected = getSelectedCategoryData(
metaboxContainer.parentElement
);
render(
createRoot( metaboxContainer ).render(
<Suspense fallback={ null }>
<CategoryMetabox initialSelected={ initialSelected } />
</Suspense>,

View File

@ -1,7 +1,9 @@
/**
* External dependencies
*/
import { render } from '@wordpress/element';
// @ts-expect-error -- @wordpress/element doesn't export createRoot until WP6.2
// eslint-disable-next-line @woocommerce/dependency-group
import { createRoot } from '@wordpress/element';
/**
* Internal dependencies
@ -10,4 +12,5 @@ import { ProductTour } from '../../guided-tours/add-product-tour/index';
const root = document.createElement( 'div' );
root.setAttribute( 'id', 'product-tour-root' );
render( <ProductTour />, document.body.appendChild( root ) );
createRoot( document.body.appendChild( root ) ).render( <ProductTour /> );

View File

@ -1,7 +1,9 @@
/**
* External dependencies
*/
import { render } from '@wordpress/element';
// @ts-expect-error -- @wordpress/element doesn't export createRoot until WP6.2
// eslint-disable-next-line @woocommerce/dependency-group
import { createRoot } from '@wordpress/element';
/**
* Internal dependencies
@ -10,4 +12,7 @@ import { VariableProductTour } from '../../guided-tours/variable-product-tour';
const root = document.createElement( 'div' );
root.setAttribute( 'id', 'variable-product-tour-root' );
render( <VariableProductTour />, document.body.appendChild( root ) );
createRoot( document.body.appendChild( root ) ).render(
<VariableProductTour />
);

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Changed from using React.render to React.createRoot for product editor areas as it has been deprecated since React 18