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

Improve error message for components in bad states (missing instance) #6990

Merged
merged 1 commit into from
Jun 8, 2016

Conversation

yungsters
Copy link
Contributor

In unknown circumstances (possible due to errors thrown elsewhere), it is possible for React components to enter a bad state where this._instance is unset but component state change can continue to happen. This leads to unhelpful error messages like:

null is not an object (evaluating 'a.componentWillReceiveProps')

This adds invariants that assert this._instance exists. If the component is in a bad state, we will now instead warn with a more descriptive error message and — more importantly — the component's name.

@@ -509,6 +509,12 @@ var ReactCompositeComponentMixin = {
return;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess we actually already fail silently here (unset in the same place as ._instance). So we don't need this check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah, will remove.

@sophiebits sophiebits added this to the 15-next milestone Jun 8, 2016
@sophiebits
Copy link
Collaborator

lgtm, feel free to "squash and merge"

@ghost ghost added the CLA Signed label Jun 8, 2016
@yungsters yungsters merged commit 7988aca into facebook:master Jun 8, 2016
@yungsters yungsters deleted the missing-instance branch June 8, 2016 00:23
@ghost
Copy link

ghost commented Jun 8, 2016

@yungsters updated the pull request.

zpao pushed a commit to zpao/react that referenced this pull request Jun 8, 2016
@keyz keyz mentioned this pull request Jun 8, 2016
7 tasks
zpao pushed a commit that referenced this pull request Jun 14, 2016
@zpao zpao modified the milestones: 15-next, 15.2.0 Jun 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants