codingtcher.com
Theme Night
Home
Login

react js sleep

Home » Tutorial Post » react js sleep

sleep in react

    sleep = (milliseconds) => {
        return new Promise(resolve => setTimeout(resolve, milliseconds))
    }
	
    componentDidUpdate(prevProps, prevState, snapshot) {
            this.sleep(5000).then(r => {
            // do something
      	    })
    }

Related Post