Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Empty destroy function prevents "state update on an unmounted component" #24069

Closed
fromflux opened this issue Mar 10, 2022 · 1 comment
Closed
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@fromflux
Copy link

fromflux commented Mar 10, 2022

Adding a useEffect with an empty clean up callback prevents async "state update after unmount" warning in certain cases.

React version: 17.0.2

Steps To Reproduce

  1. In the example provided
  2. Trigger the async request by clicking the Load button
  3. Navigate away before request resolves

Link to code example:

https://codesandbox.io/s/spring-frog-9n59kj?file=/src/LoaderPage.jsx

The current behavior

In React 17.0.2 adding a useEffect with empty clean up callback prevents the "state update on an unmounted component" warning

The expected behavior

In React 16, the warning is shown unless the clean up call back does work, for example by updating a guard "instance variable" in the vain of the "isMounted" scenario (as in https://stackoverflow.com/a/60907638).

I am not clear on what the current intention is, given #17925 and the fact that in 18.0.0-rc2 the state update is not performed after unmount in this example, with or without the empty destroy function.

@fromflux fromflux added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Mar 10, 2022
@cdscawd
Copy link

cdscawd commented Mar 11, 2022

Fuck USA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

2 participants