onComplete method need to wait for API call response #161
Answered
by
vydimitrov
DapperNerd
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
vydimitrov
Aug 5, 2021
Replies: 1 comment 2 replies
-
|
Hey, yup const [key, setKey] = useState(0)
.
.
.
<CountdownTimer
key={key}
onCopmplete={() => {
(async () => {
// do your async stuff here
// if you need to repeat the timer just set the key and the timer will start over again
setKey(prev => prev + 1)
})()
}}
/>
|
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
DapperNerd
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Hey, yup
async awaitreturnsPromise, which breaks the code sinceonCompleteexpects either an array or nothing as a returned value. You can do the following:(async() => {})()is this one