title: useState setter not updating state when called in useEffect
body: <p>Pretty much what it says on the title. When I console.log(repos) it returns an empty array. Why is the <code>repos</code> state not updating?</p>
  <pre><code>import React, { useEffect, useState } from &quot;react&quot;;
  import axios from &quot;axios&quot;;
  
  export default () =&gt; {
    const [repos, setRepos] = useState([]);
    useEffect(() =&gt; {
      (async () =&gt; {
        try {
          let repo_lists = await axios.get(
            &quot;https://api.github.com/users/Coddielam/repos&quot;
            // { params: { sort: &quot;created&quot; } }
          );
          setRepos(repo_lists.data.slice(1).slice(-10));
          console.log(repo_lists.data.slice(1).slice(-10));
          console.log(repos);
        } catch (err) {
          setRepos([
            &quot;Something went wrong while fetching GitHub Api./nPlease use the link below to view my git repos instead &quot;,
          ]);
        }
      })();
    }, []);
  
    return (
      &lt;div className=&quot;content&quot;&gt;
        &lt;h2&gt;View my recent git repos:&lt;/h2&gt;
        &lt;ul&gt;
          ...
        &lt;/ul&gt;
      &lt;/div&gt;
    );
  };
  </code></pre>