-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
sort-comp: Impossible order of getDerivedStateFromProps, state and constructor #1839
Comments
"lifecycle" only handles instance methods, since gDSFP is the first such static method (the others are static properties, or instance methods). |
@ljharb It is not quite clear what is the expected behavior. The docs says ( |
I think gDSFP should either be removed from the lifecycle list, or, it’s presence in the lifecycle list should override its inclusion in “static-methods”. |
@ljharb I made a PR (GH-1962) that enforces static lifecycles to be grouped under the lifecycle group. This seems the most reasonable behavior to me while working with lifecycle methods. This also seems to be the first guess behavior described in the docs, because |
By the way the impossible order of getDerivedStateFromProps issue seems to be fixed in GH-1858. |
I can confirm this works in the latest release 7.11.0 |
Above code reports
So I change the code
Also, the state property must be placed after the constructor. Something doesn't make sense here.
The text was updated successfully, but these errors were encountered: