title: How to change the parameter of hook in react (fetch hook)
body: <p>My fetch hook:  </p>
  
  <pre><code>  import { useEffect, useState } from "react";
  
  export const useOurApi = (initialUrl, initialData) =&gt; {
    const [url, setUrl] = useState(initialUrl);
    const [isLoading, setIsLoading] = useState(true);
    const [hasError, setHasError] = useState(false);
    const [fetchedData, setFetchedData] = useState(initialData);
  
    useEffect(() =&gt; {
      let unmounted = false;
  
      const handleFetchResponse = response =&gt; {
        if (unmounted) return initialData;
  
        setHasError(!response.ok);
        setIsLoading(false);
        return response.ok &amp;&amp; response.json ? response.json() : initialData;
      };
  
      const fetchData = () =&gt; {
        setIsLoading(true);
        return fetch(url, { credentials: 'include' })
          .then(handleFetchResponse)
          .catch(handleFetchResponse);
      };
  
      if (initialUrl &amp;&amp; !unmounted)
        fetchData().then(data =&gt; !unmounted &amp;&amp; setFetchedData(data));
  
      return () =&gt; {
        unmounted = true;
      };
    }, [url]);
  
    return { isLoading, hasError, setUrl, data: fetchedData };
  };
  </code></pre>
  
  <p>I call this hook in a function like so: </p>
  
  <pre><code>//states
      const [assignments, setAssignments] = useState([])
      const [submissions, setSubmissions] = useState([])
      const [bulk_edit, setBulk_edit]     = useState(false)
      const [ENDPOINT_URL, set_ENDPOINT_URL]  = useState('https://jsonplaceholder.typicode.com/comments?postId=1')
  
      let url = 'https://jsonplaceholder.typicode.com/comments?postId=1';
      const { data, isLoading, hasError } = useOurApi(ENDPOINT_URL, []); 
  </code></pre>
  
  <p>My question is how can I call this instance of userOurAPI with a different URL. I have tried calling it within a function where I need it but we can't call hooks within functions, so I am not sure how to pass it new url to get new data. I don't want to have many instances of userOurAPI because that is not DRY. Or is this not possible? New to hooks, so go easy on me!</p>