showing results for - "clearinterval in useeffect"
Maximiliano
18 Mar 2020
1let intervalID;
2useEffect(() => {
3    if (isRunning) {
4      intervalID = setInterval(() => {
5        dispatch({ type: "tic-toc" });
6      }, 1000);
7    }
8      return () => clearInterval(intervalID);
9  }, [isRunning]);
10