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

Prevent this.setState if there is no component #68

Closed
wants to merge 1 commit into from
Closed

Prevent this.setState if there is no component #68

wants to merge 1 commit into from

Conversation

WesSouza
Copy link

@WesSouza WesSouza commented Jun 1, 2017

On _handleDoneLeaving, prevent calling setState if the component is unmounted.

This was triggering this error:

Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the TransitionGroup component.

This happened on a very complex structure and I was not able to reproduce it with sample code.

It is related to #15.

On `_handleDoneLeaving`, prevent calling `setState` if the component is unmounted.

This was triggering this error:

> Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the ReactTransitionGroup component.
@@ -437,7 +437,7 @@ var TransitionGroup = function (_React$Component) {
if (currentChildMapping && currentChildMapping.hasOwnProperty(key)) {
// This entered again before it fully left. Add it again.
_this.performEnter(key);
} else {
} else if (component) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this component isn't the TransitionGroup instance. The error would be related to TransitionGroup not being mounted when setState is called, it'd be better to check if the current component is mounted

@jquense jquense closed this Jul 14, 2017
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

Successfully merging this pull request may close these issues.

2 participants