diff --git a/plugins/woocommerce-admin/client/settings/content.js b/plugins/woocommerce-admin/client/settings/content.js index d8acd4a2902..552b6ce70d4 100644 --- a/plugins/woocommerce-admin/client/settings/content.js +++ b/plugins/woocommerce-admin/client/settings/content.js @@ -26,6 +26,14 @@ export const Content = ( { data } ) => { return ( ); + case 'slotfill_placeholder': + return ( +
+ ); default: return null; } diff --git a/plugins/woocommerce-admin/client/settings/index.js b/plugins/woocommerce-admin/client/settings/index.js index 78c468c0985..765ca4664c7 100644 --- a/plugins/woocommerce-admin/client/settings/index.js +++ b/plugins/woocommerce-admin/client/settings/index.js @@ -2,6 +2,7 @@ * External dependencies */ import { getQuery } from '@woocommerce/navigation'; +import { useEffect } from '@wordpress/element'; /** * Internal dependencies @@ -9,12 +10,26 @@ import { getQuery } from '@woocommerce/navigation'; import { Tabs } from './tabs'; import { SectionNav } from './section-nav'; import { Content } from './content'; +import { possiblyRenderSettingsSlots } from './settings-slots'; +import { registerTaxSettingsConflictErrorFill } from './conflict-error-slotfill'; +import { registerPaymentsSettingsBannerFill } from '../payments/payments-settings-banner-slotfill'; +import { registerSiteVisibilitySlotFill } from '../launch-your-store'; import './style.scss'; const Settings = ( { params } ) => { const settingsData = window.wcSettings?.admin?.settingsPages; const { section } = getQuery(); + useEffect( () => { + possiblyRenderSettingsSlots(); + }, [ params ] ); + + useEffect( () => { + registerTaxSettingsConflictErrorFill(); + registerPaymentsSettingsBannerFill(); + registerSiteVisibilitySlotFill(); + }, [] ); + if ( ! settingsData ) { return
Error getting data
; } diff --git a/plugins/woocommerce-admin/client/settings/settings-slots.js b/plugins/woocommerce-admin/client/settings/settings-slots.js index 61d920ebf5a..8680ce03691 100644 --- a/plugins/woocommerce-admin/client/settings/settings-slots.js +++ b/plugins/woocommerce-admin/client/settings/settings-slots.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { render } from '@wordpress/element'; +import { render, createRoot } from '@wordpress/element'; import { createSlotFill, SlotFillProvider } from '@wordpress/components'; import { PluginArea } from '@wordpress/plugins'; @@ -10,6 +10,8 @@ export const SETTINGS_SLOT_FILL_CONSTANT = const { Slot } = createSlotFill( SETTINGS_SLOT_FILL_CONSTANT ); +const roots = {}; + export const possiblyRenderSettingsSlots = () => { const slots = [ { @@ -28,15 +30,39 @@ export const possiblyRenderSettingsSlots = () => { const slotDomElement = document.getElementById( slot.id ); if ( slotDomElement ) { - render( - <> - - - - - , - slotDomElement - ); + if ( createRoot ) { + if ( roots[ slot.id ] ) { + roots[ slot.id ].render( + <> + + + + + + ); + } else { + const root = createRoot( slotDomElement ); + root.render( + <> + + + + + + ); + roots[ slot.id ] = root; + } + } else { + render( + <> + + + + + , + slotDomElement + ); + } } } ); };