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: setState called after unmount #68

Open
6uliver opened this issue May 27, 2019 · 1 comment
Open

Bug: setState called after unmount #68

6uliver opened this issue May 27, 2019 · 1 comment

Comments

@6uliver
Copy link

6uliver commented May 27, 2019

After the form did unmount it is possible to run into the following warning:

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. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.

The reason is that FormWithConditionals updateConf method waited runRules Promise and then updates the state regardless the component is unmounted already.

The sequence of the events occuring this bug:

  1. FormWithConditionals mounts
  2. FormWithConditionals renders
  3. A change occurs, for example the form data has been changed
  4. updateConf triggers
  5. runRules starts
  6. FormWithConditionals gets unmounted for an external reason (for example it is conditionally rendered in other component)
  7. runRules promise gets resolved and calls setState
@dembal1990
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants