Answers for "sleep reactjs"

2

sleep in react

sleep = (milliseconds) => {
        return new Promise(resolve => setTimeout(resolve, milliseconds))
    }
	
    componentDidUpdate(prevProps, prevState, snapshot) {
            this.sleep(5000).then(r => {
            // do something
      	    })
    }
Posted by: Guest on March-10-2021
6

javascript sleep

function sleep(milliseconds) {
  const date = Date.now();
  let currentDate = null;
  do {
    currentDate = Date.now();
  } while (currentDate - date < milliseconds);
}

console.log("Hello");
sleep(2000);
console.log("World!");
Posted by: Guest on December-09-2020
1

sleep function js

function sleep(ms) {
   return new Promise(resolve => setTimeout(resolve, ms));
}
Posted by: Guest on December-31-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language