title: What is the intention of using React's useCallback hook in place of useEffect?
body: <p>I'm trying to understand what the use case is for using React's <a href="https://reactjs.org/docs/hooks-reference.html#usecallback" rel="noreferrer"><code>useCallback</code></a> hook in place of the <a href="https://reactjs.org/docs/hooks-reference.html#useeffect" rel="noreferrer"><code>useEffect</code></a> hook.</p>
  
  <p>They both appear to act as a listener for state changes of their inputs (examples taken from the <a href="https://reactjs.org/docs/hooks-reference.html" rel="noreferrer">React Docs</a>):</p>
  
  <pre><code>useEffect(
    () =&gt; {
      const subscription = props.source.subscribe();
      return () =&gt; {
        subscription.unsubscribe();
      };
    },
    [props.source],
  );
  
  const memoizedCallback = useCallback(
    () =&gt; {
      doSomething(a, b);
    },
    [a, b],
  );
  </code></pre>
  
  <p>But, the <code>useEffect</code> hook gives the additional benefit of cleaning up resources where you would have previously with <code>componentWillUnmount</code>.</p>
  
  <p>So, what is a good use case for using <code>useCallback</code>? And, what am I missing here?</p>