fix render situation

This commit is contained in:
paul sealock 2024-09-04 14:15:51 +12:00
parent ee7f1935c4
commit bdfd82cb9d
1 changed files with 2 additions and 14 deletions

View File

@ -11,8 +11,6 @@ export const SETTINGS_SLOT_FILL_CONSTANT =
// @TODO: This needs to be exposed at @woocommerce/<something> so extensions can use it. // @TODO: This needs to be exposed at @woocommerce/<something> so extensions can use it.
const { Slot } = createSlotFill( SETTINGS_SLOT_FILL_CONSTANT ); const { Slot } = createSlotFill( SETTINGS_SLOT_FILL_CONSTANT );
const roots = {};
export const possiblyRenderSettingsSlots = () => { export const possiblyRenderSettingsSlots = () => {
//@TODO We need to automatically register these based on the settings data so //@TODO We need to automatically register these based on the settings data so
// this way extensions don't need to add to this configuration. // this way extensions don't need to add to this configuration.
@ -53,17 +51,7 @@ export const possiblyRenderSettingsSlots = () => {
</> </>
); );
if ( createRoot ) { const root = createRoot( slotDomElement );
// This is a bit hacky, but we can only call render if the element is visible. root.render( slotFill );
if ( roots[ slot.id ] ) {
roots[ slot.id ].render( slotFill );
} else {
const root = createRoot( slotDomElement );
root.render( slotFill );
roots[ slot.id ] = root;
}
} else {
render( slotFill, slotDomElement );
}
} ); } );
}; };