title: How to test a function that uses prevsProps from componentDidUpdate
body: <p>Consider I have a function that is called from inside the ComponentDidUpdate. I need to unit test the canCheck function.</p>
  <pre><code>ComponentDidUpdate(prevProps,prevState){
     if(prevState.isFull){
       callA();
     }
     if(canCheck(prevProps)){
       callB()
     }
  }
  </code></pre>
  <p>The canCheck function is as follows</p>
  <pre><code>canCheck(prevProps){
      const {
        isFocused,
        getTheStartState,
        index,
        loading
      } = this.props;
      if (!isFocused) {
        return false;
      }
      return (
        index === 0 &amp;&amp;
        prevProps.getTheStartState &amp;&amp;
        !getTheStartState &amp;&amp;
        !loading
      );
  }
  </code></pre>
  <p>Things I have tried include</p>
  <pre><code>const ShallowRenderer = require('react-test-renderer/shallow');
  describe('canCheck', () =&gt; {
    test('should return correctly value', () =&gt; {
      const renderer = new ShallowRenderer();
      renderer.render(
        &lt;TestContainer
          isFocused
          getTheStart
          {...dummy}
        /&gt;
      );
      const instance = renderer.getMountedInstance();
      instance.componentDidUpdate(
        {
          getTheStartState: false
          loading: true
        },
        { someState: true }
      );
      expect(renderer.getMountedInstance().canCheck()).toBeFalsy();
    });
  });
  
  </code></pre>
  <p>Though I have mentioned <code>getTheStartState</code> in the prevProps of <code>componentDidUpdate</code> I always get the error as cannot read getTheStartState of undefined. Are there any suggestions of how we can unit test such function, I could not find much resource for this online!</p>