title: React hooks with async fetch
body: <p>I'm new to React hooks, but I'm trying to use a <code>useEffect</code> with a <code>useCallback</code>, but getting the notorious <code>React Hook "useList" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function  react-hooks/rules-of-hooks</code> error.</p>
  
  <p>Thie file holds the makeRequest:</p>
  
  <pre><code>function useConnections = () =&gt; {
      const makeRequest = React.useCallback(async (props) =&gt; {
          // Determine base url, determine headers here
          const response = fetch(url, options);
  
          return response;
      }
  
      return { makeRequest };
  }
  </code></pre>
  
  <p>This file is my <code>useListProvider</code>:</p>
  
  <pre><code>function useListProvider = () =&gt; {
      const { makeRequest } = useConnections();
  
      const useList = React.useCallback(async (props) =&gt; {
          // makerequest is just a wrapper for fetch with a bunch of needed headers.
          const response = await makeRequest(props);
  
          return { body: response.body };
      }
  
      return { useList };
  }
  </code></pre>
  
  <p>This is the rendered page:</p>
  
  <pre><code>function MainPage() {
      const [isBusy, setIsBusy] = React.useStore(false);
      const { useList } = useListProvider();
  
      React.useEffect(() =&gt; {
          if (!isBusy) { useList(); setIsBusy(false); } // ERROR HERE!
      }, [useList]);
  
      return (
          &lt;React.Fragment&gt;
              IsBusy: {isBusy}
          &lt;/React.Fragment&gt;
      );
  }
  </code></pre>
  
  <p>Maybe I'm not getting it, but I only want to grab the useList data when the state says it's not busy.  However, doing it this way, I get the error listed above. I understand I can't think of this the same way as Component classes, but how would you approach single and multiple renders from a callback?</p>
  
  <p>I'm not entirely sure what is happening here because I'm doing something similar in the useConnections, etc. and not getting the same error?</p>