I have encounter a really weird issue in react-native on iOS simulation, the following async function run fine after the first build, if I reload then seems like the await function got frozen. If I deleted the app and rebuild again, then it will run fine
const processPayment = async (amount: number) => {
console.log("start fetching")
const data = await new Promise((resolve, reject) => {
setTimeout(() => {
resolve({ item: 10 })
}, 1000)
})
console.log(data)
console.log("end fetching")
}
console log before reload, can run multiple times
LOG start fetching
LOG {"item": 10}
LOG end fetching
console log after reload
LOG start fetching
Calling function
<TouchableOpacity onPress={() => {processPayment(100)}}>
<Text style={styles.keypad}>PAY</Text>
</TouchableOpacity