settimeout in react
snippet in javascript

settimeout in react

user7722

  useEffect(() => {
   const timeout = setTimeout(() => {
      history.push('/dashboard');
    }, 3000);
  },[]);

react timeout function

user5175

useEffect(() => {
  const timer = setTimeout(() => {
    console.log('This will run after 1 second!')
  }, 1000);
  return () => clearTimeout(timer);
}, []);