title: Can not update state inside setInterval in react hook
body: <p>I want to update state every second inside setinterval() but it doesn't work.
  I am new to react hook so can not understand why this is happening.
  Please take a look at the following code snippet and give me advice.</p>
  
  <pre><code>// State definition
  
  const [gamePlayTime, setGamePlayTime] = React.useState(100);
  let targetShowTime = 3;
  .........................
  // call function
  React.useEffect(() =&gt; {
      gameStart();
    }, []);
  .............
  
  const gameStart = () =&gt; {
      gameStartInternal = setInterval(() =&gt; {
        console.log(gamePlayTime); //always prints 100
        if (gamePlayTime % targetShowTime === 0) {
  
          //can not get inside here
  
          const random = (Math.floor(Math.random() * 10000) % wp("70")) + wp("10");
          const targetPosition = { x: random, y: hp("90") };
          const spinInfoData = getspinArray()[Math.floor(Math.random() * 10) % 4];
          NewSpinShow(targetPosition, spinInfoData, spinSpeed);
        }
        setGamePlayTime(gamePlayTime - 1);
      }, 1000);
    };
  
  </code></pre>