title: Setting state in useEffect hook does not change state value
body: <p>am writing an app in react native and i got a problem with useState and useEffect hooks. I would like to change increment state value by one every 10 seconds.</p>
  <p>Here is my code:</p>
  <pre><code>const [tripDistance, setTripDistance] = useState(0);
  
  useEffect(() =&gt; {
    const interval = setInterval(() =&gt; {
      setTripDistance((prevState) =&gt; prevState + 1);
  
      console.log(tripDistance);
    }, 10000);
    return () =&gt; {
      clearInterval(interval);
    };
  }, []);
  </code></pre>
  <p>but the output from the console.log is always 0.</p>
  <p>What am I doing wrong?</p>