Skip to content

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

Merged
yungsters merged 1 commit into
react:masterfrom
yungsters:missing-instance
Jun 8, 2016
Merged

yungsters merged 1 commit into
react:masterfrom
yungsters:missing-instance

Conversation

@yungsters

Copy link
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

lgtm, feel free to "squash and merge"

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

ghost commented Jun 8, 2016

Copy link
Copy Markdown

@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