JavaScript SetTimeout
setTimeout(function(){
alert("Sup!");
}, 2000);//wait 2 seconds
Grepper
setTimeout(function(){
alert("Sup!");
}, 2000);//wait 2 seconds
setTimeout(function(){ alert("Hello"); }, 3000);
setTimeout(function(){
//code goes here
}, 2000); //Time before execution
setTimeout(function(){
console.log("hello");
}, 3000); //wait for atleast 3 seconds before console logging
setTimeout(function(){
$('#overlay'). modal('hide')
}, 5000);
//#overlay will be the ID of modal which you want to hide or show modal
import React, { useState, useEffect } from "react";
export default function App() {
const [count, setCount] = useState(0);
useEffect(() => {
const timeout = setTimeout(() => {
setCount(1);
}, 3000);
},[]);
return (
<div className="App">
<h1>{count}</h1>
<button onClick={() => setCount(count + 1)}>Increment</button>
</div>
);
}