Skip to content

Commit

Permalink
Fix Vue error in MoonpayModal
Browse files Browse the repository at this point in the history
Calling onBeforeUnmount is not allowed outside the setup() function, and because onMount has an async callback, that callback is outside the setup() function.
  • Loading branch information
sisou committed Jul 5, 2023
1 parent d671f4d commit e1797f8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/modals/MoonpayModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,12 @@ export default defineComponent({
const widgetReady = ref(false);
let widget: any;
onMounted(async () => {
await loadScript('MoonPayWebSdk', 'https://static.moonpay.com/web-sdk/v1/moonpay-web-sdk.min.js');
const widget = window.MoonPayWebSdk.init({
widget = window.MoonPayWebSdk.init({
debug: config.environment !== ENV_MAIN,
flow: props.flow,
environment: config.environment === ENV_MAIN ? 'production' : 'sandbox',
Expand Down Expand Up @@ -156,10 +158,10 @@ export default defineComponent({
widget.show();
widgetReady.value = true;
onBeforeUnmount(() => widget.close());
});
onBeforeUnmount(() => widget && widget.close());
async function sendBitcoin(properties: InitiateDepositProperties) {
try {
const value = parseInt(properties.cryptoCurrencyAmountSmallestDenomination, 10);
Expand Down

0 comments on commit e1797f8

Please sign in to comment.