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

Make setState in render a warning, not an invariant #4091

Merged
merged 1 commit into from
Jun 12, 2015

Conversation

sebmarkbage
Copy link
Collaborator

We keep track of the fact that something is rendering for a bunch of
warnings. (ReactCurrentOwner.current !== null)

Once we get rid of owner for string refs, I'll convert those to something
like "isRendering" instead. The interesting part is that feature is
__DEV__ only. It is only used for warnings. Except for this one case.

This means that we can get rid of the special case for the isRendering
stack on in prod.

We keep track of the fact that something is rendering for a bunch of
warnings. (ReactCurrentOwner.current !== null)

Once we get rid of owner for string refs, I'll convert those to something
like "isRendering" instead. The interesting part is that feature `__DEV__`
only. It is only used for warnings. Except for this case.

This means that we can get rid of the special case for the isRendering
stack on in prod.
render: function() {
renderedState = this.state.value;
if (this.state.value === 0) {
this.setState({ value: 1 });
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: {value: 1} like you had in getInitialState

@sophiebits
Copy link
Collaborator

👍

sebmarkbage added a commit that referenced this pull request Jun 12, 2015
Make setState in render a warning, not an invariant
@sebmarkbage sebmarkbage merged commit a1cf88b into facebook:master Jun 12, 2015
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