title: Unmounts & useState in async callbacks
body: <p>In React FC's, is fetching directly inside async callbacks an anti-pattern?</p>
  <p>Is it okay for the <code>setState</code> to be called <em><strong>after</strong></em> the component unmounts?</p>
  <pre><code>const Component = () =&gt; {
    const [state, setState] = useState(&quot;&quot;);
  
    const onClick = e =&gt; {
      // What if the component unmounts before setState?
      fetch(&quot;url&quot;).then(response =&gt; response.json()).then(json =&gt; setState(json))
    }
    return &lt;button onClick={onClick}&gt;&lt;/button&gt;
  }
  </code></pre>