Answers for "how to wait command react"

10

wait javascript

wait(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
 }
Posted by: Guest on June-19-2020
2

javascript sleep function

sleep = milliseconds => new Promise(resolve => setTimeout(resolve, milliseconds));

//        V  Must add this async keyword
sayHi = async () => {
  	// V Must include await
	await sleep(1000); // Sleep 1000 milliseconds (1 second)
  	console.log('Hi');
  	// Rest of code...
}
Posted by: Guest on November-30-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language