-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Remove irrelevant suggestion of a legacy method from a warning #13169
Conversation
'be a pure function of props and state; constructor side-effects are ' + | ||
'an anti-pattern, but can be moved to `componentWillMount`.', | ||
'be a pure function of props and state. ' + | ||
'Move the setState call to componentDidMount`.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is too prescriptive. We don't actually know they called setState in constructor, or that they want to move it to cDM (setting it in constructor might be better in most cases).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gaearon I agree:) Whatever, i thought deprecated lifecycle error message should be deleted! As you say, I will fix pr by setting warn message by deleting message about prescriptive message (constructor and cDM)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gaearon is it ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i fixed pr!
'be a pure function of props and state; constructor side-effects are ' + | ||
'an anti-pattern, but can be moved to `componentWillMount`.', | ||
'be a pure function of props and state. ' + | ||
'Move the setState call to componentDidMount`.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gaearon I agree:) Whatever, i thought deprecated lifecycle error message should be deleted! As you say, I will fix pr by setting warn message by deleting message about prescriptive message (constructor and cDM)
'be a pure function of props and state; constructor side-effects are ' + | ||
'an anti-pattern, but can be moved to `componentWillMount`.', | ||
'be a pure function of props and state. ' + | ||
'Move the setState call to componentDidMount`.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gaearon is it ok?
Hi @zx6658 , |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is right. It seems like this code path only runs for setState in render, and not for constructor. The constructor message is different and is specified by the noop queue in the isomorphic package.
As react version is updated and some lifecycle is deprecated, warn message should be changed like in my pr :)
Warning Content:
Cannot update during an existing state transition (such as withinrenderor another component's constructor). Render methods should be a pure function of props and state; constructor side-effects are an anti-pattern, but can be moved to componentWillMount.
What is the expected behavior?
I thought, warning messages what use deprecated lifecycle method should be changed!! :)