title: Testing Custom Hook and useEffect Not Firing
body: <p>I am testing a small custom hook and I can't get the <code>useEffect</code> inside of it to fire. I have the hook in a mounted component and have tested other custom hooks that do not have a <code>useEffect</code> with this method successfully.
  The ref gets set to <code>false</code> as expected (and breaks as expected when set to <code>true</code>), but it never updates to <code>true</code> when <code>useEffect</code> should have ran. The code works when ran outside of a test.</p>
  
  <p>My hook:</p>
  
  <pre><code>export default function useIsComponentMounted() {
      const isMountedRef = useRef(false);
      useEffect(() =&gt; {
          isMountedRef.current = true;
          return function cleanup() {
              isMountedRef.current = false;
          };
      }, []);
      return isMountedRef.current;
  }
  </code></pre>
  
  <p>My method of mounting:</p>
  
  <pre><code>function TestHook(props) {
      const { callback } = props;
      callback();
      return &lt;div /&gt;;
  }
  
  export const testHook = callback =&gt; mount(&lt;TestHook callback={callback} /&gt;);
  </code></pre>
  
  <p>My Test:</p>
  
  <pre><code>describe('useIsComponentMounted', () =&gt; {
      it('should keep track of if a component is mounted', () =&gt; {
          let expected = true;
          let mounted;
          const component = testHook(() =&gt; {
              mounted = useIsComponentMounted();
          });
          expect(mounted).toBe(expected);
          component.unmount();
          expected = false;
          expect(mounted).toBe(expected);
      });
  });
  </code></pre>