time sleep in react code example
Example: sleep in react
sleep = (milliseconds) => {
return new Promise(resolve => setTimeout(resolve, milliseconds))
}
componentDidUpdate(prevProps, prevState, snapshot) {
this.sleep(5000).then(r => {
// do something
})
}