skip to Main Content

Reactjs – How to use useState, Dispatch input?

Consider this code: const [seconds, setSeconds] = useState<number>(START_VALUE); useEffect(() => { const intervalId = setInterval(() => { setSeconds((previousSeconds) => previousSeconds - 1); }, 1000); if (seconds <= 0) { clearInterval(intervalId); functionX(); } return () => clearInterval(intervalId); }, [seconds]); The problem…

VIEW QUESTION
Back To Top
Search