#IvonneVargas
1 messages · Page 1 of 1 (latest)
Hello! Can you share your code? When you say you get no response what does that mean exactly? Does the code hang?
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
This is the React Native SDK, correct?
Does the app freeze at this point?
It doesn't freeze, the promise just never comes
No matter how long you wait?
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?
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
It's deprecated, but it should still work. Maybe try isPlatformPaySupported instead though? https://stripe.dev/stripe-react-native/api-reference/index.html#isApplePaySupported
nop
Same issue?
I think the problem is that componentDidMount won't work as an async function.
previously I tried to use isPlatformPaySupported but being the sdk version 0.19 they told me that I should use isApplePaySupported
Yeah, here, have a look at this: https://stackoverflow.com/a/51862402/
mmmm
I've used it before like this and with other libraries if it works... it's quite rare
Can you try one of those approaches and see if that solves the issue?
but isApplePaySupported is being used correctly right?
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.
So what is the correct way?
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.
What do you mean?
I put a button that calls an async function and put await isApplePaySupported(); and the same thing happens... the promise does not return
Can you show me the code you're using to call the function?
ooh it works!! just change the variable name
let isApplePayEnabled = await isApplePaySupported();
and it worked!
👍
Ah, okay, good!
thank you so much!!!
Happy to help!