fix: wcadmin react18 createroot shipping settings, payment method, wc beta tester (#48835)

This commit is contained in:
RJ 2024-07-29 21:30:03 +08:00 committed by GitHub
parent 31c4ae8431
commit a92fbcaa07
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 21 additions and 17 deletions

View File

@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { render } from '@wordpress/element';
import { createRoot } from '@wordpress/element';
/**
* Internal dependencies
@ -10,9 +10,8 @@ import { BetaFeaturesTrackingContainer } from './container';
import './style.scss';
const betaFeaturesRoot = document.createElement( 'div' );
betaFeaturesRoot.setAttribute( 'id', 'beta-features-tracking' );
render(
<BetaFeaturesTrackingContainer />,
document.body.appendChild( betaFeaturesRoot )
betaFeaturesRoot.setAttribute( 'id', 'beta-features-tracking' );
createRoot( document.body.appendChild( betaFeaturesRoot ) ).render(
<BetaFeaturesTrackingContainer />
);

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
@ -34,7 +36,7 @@ PAYMENT_METHOD_PROMOTIONS.forEach( ( paymentMethod ) => {
);
const subTitle = container.getElementsByClassName( 'gateway-subtitle' );
render(
createRoot( container ).render(
<PaymentPromotionRow
columns={ columns }
paymentMethod={ paymentMethod }
@ -42,8 +44,7 @@ PAYMENT_METHOD_PROMOTIONS.forEach( ( paymentMethod ) => {
subTitleContent={
subTitle.length === 1 ? subTitle[ 0 ].innerHTML : undefined
}
/>,
container
/>
);
}
} );

View File

@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { render, createRoot } from '@wordpress/element';
import { createRoot } from '@wordpress/element';
/**
* Internal dependencies
@ -24,9 +24,5 @@ const ShippingApp = () => (
);
if ( shippingZoneRegionPickerRoot ) {
if ( createRoot ) {
createRoot( shippingZoneRegionPickerRoot ).render( <ShippingApp /> );
} else {
render( <ShippingApp />, shippingZoneRegionPickerRoot );
}
createRoot( shippingZoneRegionPickerRoot ).render( <ShippingApp /> );
}

View File

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

View File

@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { render } from '@wordpress/element';
import { createRoot } from '@wordpress/element';
/**
* Internal dependencies
@ -16,7 +16,7 @@ const appRoot = document.getElementById(
);
if ( appRoot ) {
render( <App />, appRoot );
createRoot( appRoot ).render( <App /> );
}
registerProductEditorDevTools();

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Changed from using React.render to React.createRoot for payment methods promotion, shipping settings region zone as it has been deprecated since React 18