title: returning promise from useEffect
body: <p>I was going through the article <a href="https://www.robinwieruch.de/react-hooks-fetch-data" rel="nofollow noreferrer">https://www.robinwieruch.de/react-hooks-fetch-data</a>.</p>
  <p>It gives the below 2 snippets to demonstrate how to deal with promises in useEffect. The first one throws an error while to second one doesnt.</p>
  <p>first snippet -</p>
  <pre><code>  useEffect(async () =&gt; {
      const result = await axios(
        'https://hn.algolia.com/api/v1/search?query=redux',
      );
   
      setData(result.data);
    }, []);
  </code></pre>
  <p>second snippet -</p>
  <pre><code>useEffect(() =&gt; {
      const fetchData = async () =&gt; {
        const result = await axios(
          'https://hn.algolia.com/api/v1/search?query=redux',
        );
   
        setData(result.data);
      };
   
      fetchData();
    }, []);
  </code></pre>
  <p>Why does the second not throw an error, when <code>fetchdata()</code> is called it will return a promise, and thus a promise will be returned from <code>useEffect</code> too. How is the second snippet different from the first one ?</p>