Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

sleep in react

    sleep = (milliseconds) => {
        return new Promise(resolve => setTimeout(resolve, milliseconds))
    }
	
    componentDidUpdate(prevProps, prevState, snapshot) {
            this.sleep(5000).then(r => {
            // do something
      	    })
    }
 
PREVIOUS NEXT
Tagged: #sleep #react
ADD COMMENT
Topic
Name
8+8 =