title: Cannot get rid of Warning: React state update on unmounted component during tests RTL
body: <p>I'm writing integration tests.  This file renders the <code>&lt;App /&gt;</code>, fills an input, and submits a search before each test.  The tests all pass.  However, I cannot get rid of:</p>
  <pre><code>Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application.
  </code></pre>
  <p>I don't get this warning in the app, only tests.  I've read dozens of posts but none of the solutions (<code>act()</code>, <code>wait()</code>, <code>waitFor()</code>, etc...) make any difference.</p>
  <p>Here is the test code, I've left the bare minimum of what causes the warning (where I grab <code>goBackBtnText</code> after clicking the <code>submitBtn</code>:</p>
  <pre><code>describe('Results Page', () =&gt; {
    let goBackBtn, nearbyBtn;
    beforeEach(async () =&gt; {
      ZIP_API_MOCK();
      FDIC_API_MOCK();
      render(&lt;App /&gt;);
  
      const zipInput = await screen.findByPlaceholderText(searchFormText.placeholder);
      const submitBtn = screen.getByText(searchFormText.submitBtn).closest('button');
      input(zipInput, VALID_ZIP_WITH_RESULTS);
      userEvent.click(submitBtn);
      const goBackBtnText = await screen.findByText((content) =&gt;
        content.includes(resultsText.goBackBtn)
      );
      goBackBtn = goBackBtnText.closest('button');
    });
  
    afterEach(() =&gt; {
      userEvent.click(goBackBtn);
    });
  
    it('true', () =&gt; {
      expect(true).toBeTruthy();
    });
  
  </code></pre>
  <p>The line where the warning is thrown:</p>
  <pre><code> 44 |     }
        45 |     if (newResults.fiList.length &gt; 0) fwdToPath = PATHS.RESULTS;
      &gt; 46 |     setResults(newResults);
           |     ^
        47 |     setLoading(false);
        48 |   };
  </code></pre>
  <p>And this is what really confuses me.  Because <code>goBackBtn</code> is on the results page and the test successfully sees it. So <code>setResults</code> has already been run and a side effect has been executed which is to redirect to the results page.</p>
  <p>I'm aware I'm misunderstanding something, just not sure what anymore.  Appreciate any help!</p>