diff --git a/src/Payments/PreMountLoader.res b/src/Payments/PreMountLoader.res index 305ebb686..b35d5f5a7 100644 --- a/src/Payments/PreMountLoader.res +++ b/src/Payments/PreMountLoader.res @@ -137,15 +137,26 @@ let make = ( }) React.useEffect4(() => { - if ( - paymentMethodsResponseSent && - customerPaymentMethodsResponseSent && - sessionTokensResponseSent && - savedPaymentMethodsResponseSent - ) { + let handleUnmount = () => { handlePostMessage([("preMountLoaderIframeUnMount", true->JSON.Encode.bool)]) Window.removeEventListener("message", handle) } + + switch hyperComponentName { + | Elements => + if ( + paymentMethodsResponseSent && + customerPaymentMethodsResponseSent && + sessionTokensResponseSent + ) { + handleUnmount() + } + | PaymentMethodsManagementElements => + if savedPaymentMethodsResponseSent { + handleUnmount() + } + } + None }, ( paymentMethodsResponseSent,