Skip to content

Commit

Permalink
fix: premount loader fix (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
PritishBudhiraja authored Jul 11, 2024
1 parent b019c64 commit f9d973c
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/Payments/PreMountLoader.res
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f9d973c

Please sign in to comment.