title: how to fix increments fn timer app in react
body: <p>hello dev's iam tring to build timer pomodoro react app
  my problem is when i start call function that increments timer with setInterval its returns 0 and 1 and repeat 0 and 1 No more than 0 and 1</p>
  <p>my code is :</p>
  <pre><code>import React, { useRef, useState } from &quot;react&quot;;
  import Timer from &quot;./Timer&quot;;
  import styles from &quot;../css/pomodoro.module.css&quot;;
  
  const Pomodoro = () =&gt; {
    const [start, setStart] = useState(false);
    const [intervalRef, setIntervalRef] = useState(0);
    const [cycles, setCycles] = useState(0);
    const [seconds, setSeconds] = useState(0);
    const [minutes, setMinutes] = useState(0);
  
    const startTimer = () =&gt; {
      return setInterval(() =&gt; {
        seconds &lt;= 59 ? setSeconds(seconds + 1) : setSeconds(0);
      }, 1000);
    };
  
    const stopTimer = () =&gt; {
      clearInterval(intervalRef);
    };
  
    function handleStartPomodoro() {
      setStart(!start);
      if (start === false) {
        setIntervalRef(startTimer());
        startTimer();
        console.log(&quot;start&quot;);
      }
      if (start === true) {
        stopTimer();
        console.log(&quot;stop&quot;);
      }
    }
  
    return (
      &lt;div className={styles[&quot;app-wrapper&quot;]}&gt;
        &lt;Timer seconds={seconds} minutes={minutes} /&gt;
        &lt;div className={styles[&quot;buttons-wrapper&quot;]}&gt;
          &lt;button type=&quot;button&quot; onClick={() =&gt; handleStartPomodoro()}&gt;
            Start
          &lt;/button&gt;
          &lt;button type=&quot;button&quot;&gt; reset&lt;/button&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    );
  };
  
  export default Pomodoro;
  </code></pre>