react-jsonschema-form-conditionals
react-jsonschema-form-conditionals copied to clipboard
Bug: setState called after unmount
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:
- FormWithConditionals mounts
- FormWithConditionals renders
- A change occurs, for example the form data has been changed
- updateConf triggers
- runRules starts
- FormWithConditionals gets unmounted for an external reason (for example it is conditionally rendered in other component)
- runRules promise gets resolved and calls setState
+1