Closed kelokchan closed 4 years ago
put Alert.alert('Success')
in a setTimeout with 1-second delay and try what happens.
That would work. Is there a better, less hacky way?
@kelokchan Kelok the problem lies in these two lines
setVisible(false);
Alert.alert('Success')
State updates are async and here you're trying to show an Alert while the previous Modal isn't dismissed yet. The setTimeout
call was for my confirmation.
In terms of pseudo-code, you want to hide the alert, and after it is dismissed show another alert. The classic way of doing it with setState
was to use the callback, you'd write like setState({ visible: false }, () => do something)
. Look at useEffect
hook and you should be able to google your way towards a solution.
I'm currently using
AwesomeAlert
as a spinner. I have an API call that will setshow
to false to close theAwesomeAlert
fireAlert.alert()
whenever the response is received. The problem is, whenever the spinner is closed, my successfulAlert
will be dismissed altogether. Any idea why?