title: How to convert functional component using hooks to class component
body: <p>I'm trying to challenge myself to convert my course project that uses hooks into the same project but without having to use hooks in order to learn more about how to do things with class components. Currently, I need help figuring out how to replicate the <code>useCallback</code> hook within a normal class component. Here is how it is used in the app.</p>
  <pre><code>export const useMovieFetch = movieId =&gt; {
      const [state, setState] = useState({});
      const [loading, setLoading] = useState(true);
      const [error, setError] = useState(false);
  
      const fetchData = useCallback(async () =&gt; {
          setError(false);
          setLoading(true);
  
          try{
              const endpoint = `${API_URL}movie/${movieId}?api_key=${API_KEY}`;
              const result = await(await fetch(endpoint)).json();
              const creditsEndpoint = `${API_URL}movie/${movieId}/credits?api_key=${API_KEY}`;
              const creditsResult = await (await fetch(creditsEndpoint)).json();
              const directors = creditsResult.crew.filter(member =&gt; member.job === 'Director');
              
              setState({
                  ...result,
                  actors: creditsResult.cast,
                  directors
              });
  
          }catch(error){
              setError(true);
              console.log(error);
          }
          setLoading(false);
      }, [movieId])
  
  useEffect(() =&gt; {
          if(localStorage[movieId]){
              // console.log(&quot;grabbing from localStorage&quot;);
              setState(JSON.parse(localStorage[movieId]));
              setLoading(false);
          }else{
              // console.log(&quot;Grabbing from API&quot;);
              fetchData();
          }
      }, [fetchData, movieId])
  
      useEffect(() =&gt; {
          localStorage.setItem(movieId, JSON.stringify(state));
      }, [movieId, state])
  
      return [state, loading, error]
  }
  </code></pre>
  <p>I understand how to replicate other hooks such as <code>useState</code> and <code>useEffect</code> but I'm struggling to find the answer for the alternative to <code>useCallback</code>. Thank you for any effort put into this question.</p>