#IvonneVargas

1 messages · Page 1 of 1 (latest)

ancient thicketBOT
vocal night
#

Hello! Can you share your code? When you say you get no response what does that mean exactly? Does the code hang?

paper pumice
#

async componentDidMount() {
console.log("componentDidMount " + isApplePaySupported);
let isApplePaySupported = await isApplePaySupported();
console.log("isApplePaySupported: " + isApplePaySupported);
}

#

doesn't return a response, it just prints the first console but the second doesn't anymore

vocal night
#

This is the React Native SDK, correct?

paper pumice
#

"@stripe/stripe-react-native": "0.19.0"

#

my app is oriented to ios 12

vocal night
#

Does the app freeze at this point?

paper pumice
#

It doesn't freeze, the promise just never comes

vocal night
#

No matter how long you wait?

paper pumice
#

the promise of await isApplePaySupported();

#

exactly never comes

vocal night
#

That's strange. And that's the exact code you're using with no edits?

#

Where is componentDidMount() being called from? Perhaps it's being called without await?

paper pumice
#

yes it is exactly the code

#

My app is a component class, so componentDidMount is called when the screen is mounted.

#

It is correct to use isApplePaySupported ?

#

In the chat they gave me the example of the sdk 0.19 but it uses hooks, and I don't use hooks because it is an app with class components

vocal night
paper pumice
#

nop

vocal night
#

Same issue?

#

I think the problem is that componentDidMount won't work as an async function.

paper pumice
#

previously I tried to use isPlatformPaySupported but being the sdk version 0.19 they told me that I should use isApplePaySupported

vocal night
paper pumice
#

mmmm

#

I've used it before like this and with other libraries if it works... it's quite rare

vocal night
#

Can you try one of those approaches and see if that solves the issue?

paper pumice
#

but isApplePaySupported is being used correctly right?

vocal night
#

I mean, no, I don't think so? It returns a promise, but you're using it with await in a function that isn't being called in a way that supports async operations.

paper pumice
#

So what is the correct way?

vocal night
#

If you still want to use componentDidMount you would need to use one of the approaches outlined in the answer I linked to.

#

Alternatively you can call it somewhere else where async/await is supported properly.

paper pumice
#

Ok I will try, thanks

#

It doesn't work the same if I call it from another function

vocal night
#

What do you mean?

paper pumice
#

I put a button that calls an async function and put await isApplePaySupported(); and the same thing happens... the promise does not return

vocal night
#

Can you show me the code you're using to call the function?

paper pumice
#

ooh it works!! just change the variable name

#

let isApplePayEnabled = await isApplePaySupported();

#

and it worked!

#

👍

vocal night
#

Ah, okay, good!

paper pumice
#

thank you so much!!!

vocal night
#

Happy to help!