React timer application
let vs const is fundamentally an ES6+ issue:



constCreates a constant whose scope can be either global or local to the block in which it is declared. An initializer for a constant is required. You must specify its value in the same statement in which it's declared.


// wrong
const timer;
// Uncaught SyntaxError: Missing initializer in const declaration

// right
const timer = 60;



letAllows you to declare variables that are limited to a scope of a block statement, or expression on which it is used, unlike the var keyword, which defines a variable globally, or locally to an entire function regardless of block scope. Please note that a let variable is initialized to a value only when a parser evaluates it.


function do_something() {
  console.log(bar); // undefined
  console.log(foo); // ReferenceError
  var bar = 1;
  let foo = 2;
};


With that said, change the declaration to let timer;

// Within the first `useEffect`
useEffect(() =&gt; {
     let timer; // change this
     if (secCount &gt; 0) {
       timer = setInterval(() =&gt; {setSecCount(secCount - 1)}, oneSec);
     }
     if (secCount === 0 &amp;&amp; minCount &gt; 0) {
       timer = setInterval(() =&gt; {setSecCount(60)}, oneSec);
     }
     return () =&gt; clearInterval(timer);
   }, [secCount]);
```