Skip to content

Commit

Permalink
fix: destroys PostMessageHandler on unmount (#2047)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwhardwick authored Aug 1, 2024
1 parent 25c1fd6 commit 846ac8f
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@ export function CheckoutContextProvider({ values, children }: CheckoutContextPro
}, [checkoutAppIframe, checkout]);

useEffect(() => {
if (!provider || !postMessageHandler) return;
if (!provider || !postMessageHandler) return undefined;
checkoutDispatch({
payload: {
type: CheckoutActions.SET_PROVIDER_RELAY,
providerRelay: new ProviderRelay(postMessageHandler, provider),
},
});

return () => {
postMessageHandler?.destroy();
};
}, [provider, postMessageHandler]);

return (
Expand Down

0 comments on commit 846ac8f

Please sign in to comment.