title: ShallowWrapper::setState() can only be called on class components
body: <p>this test was passing before i using <code>withSnackbar</code>. but now it fails and i really don't know how to fix that. So any help will be appreciated. Thanks.</p>
  
  <p>Here is my export in the component:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>export default withSnackbar(StoryApp)</code></pre>
  </div>
  </div>
  </p>
  
  <p>And here is my test:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let story = {
    Title: "title 1",
    body: "body 1",
    UserEntityKey: "userEntityKey",
    Key: "storyKey"
  }
  
  afterEach(() =&gt; {
    // cleaning up the mess left behind the previous test
    MockAxios.reset();
  });
  
  test('Story deletes based on mocked backend response', async () =&gt; {
    window.confirm = jest.fn()
    window.confirm.mockReturnValue(1);
  
    let idToken = "asdf"
  
    MockAxios.delete.mockImplementationOnce(() =&gt;
      Promise.resolve(story.Key)
    )
  
    const storyApp = shallow(&lt;StoryApp /&gt;);
  
    storyApp.setState((prev) =&gt; {
      prev.data.push(story)
      return prev
    })
  
    // Test without idToken
    await storyApp.instance().deleteStory(story)
    expect(MockAxios.delete).not.toHaveBeenCalled();
    expect(storyApp.state().data.length).toEqual(1)
  
    // Test with idToken
    storyApp.setState((prev) =&gt; {
      prev.user = { idToken: idToken }
      return prev
    })
    await storyApp.instance().deleteStory(story)
    expect(MockAxios.delete).toHaveBeenCalledWith(apiUrl + '?key=' + story.Key, { headers: { 'Authorization': idToken } });
    expect(storyApp.state().data.length).toEqual(0)
  })</code></pre>
  </div>
  </div>
  </p>
  
  <p>And here is the output:</p>
  
  <p>● Story deletes based on mocked backend response</p>
  
  <pre><code>ShallowWrapper::setState() can only be called on class components
  
    101 |   const storyApp = shallow(&lt;StoryApp /&gt;);
    102 | 
  &gt; 103 |   storyApp.setState((prev) =&gt; {
        |            ^
    104 |     prev.data.push(story)
    105 |     return prev
    106 |   })
  
    at ShallowWrapper.setState (node_modules/enzyme/build/ShallowWrapper.js:639:17)
    at Object.setState (__tests__/App.test.js:103:12)
    at tryCatch (node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:288:22)
    at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:114:21)
    at asyncGeneratorStep (__tests__/App.test.js:25:103)
    at _next (__tests__/App.test.js:27:194)
    at __tests__/App.test.js:27:364
    at Object.&lt;anonymous&gt; (__tests__/App.test.js:27:97)
  </code></pre>