title: React setState hook not working with useEffect
body: <p>I have the following code. The idea is to create a simple loading for a mock component</p>
  
  <pre><code>const [loading, setLoading] = useState(false)
  
    function mockLoading () {
      setLoading(true)
      console.log('1', loading)
      setTimeout(() =&gt; {
        setLoading(false)
        console.log('2', loading)
      }, 3000)
    }
  
    useEffect(() =&gt; {
      mockLoading()
    }, []);
  </code></pre>
  
  <p>But for some reason, setLoading is not working.
  Console.log 1 and 2 both are false</p>