react/sort-comp: getDerivedStateFromProps
See original GitHub issueAfter updating to v17, I am getting 'getDerivedStateFromProps should be placed after componentDidUpdate`. I want to say previously in v16 the rule was below the constructor… does the new placement make sense?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7
Top Results From Across the Web
sort-comp: Impossible order of getDerivedStateFromProps ...
@ljharb I made a PR (GH-1962) that enforces static lifecycles to be grouped under the lifecycle group. This seems the most reasonable behavior ......
Read more >React.Component
These methods are called in the following order when a component is being re-rendered: static getDerivedStateFromProps(); shouldComponentUpdate(); render() ...
Read more >Why getDerivedStateFromProps does not allow to re- ...
I use a setState right after this data.splice in order to tigger the component update and, if I scope componentDidUpdate() I saw the...
Read more >React.js static getDerivedStateFromProps()
The getDerivedStateFromProps() method is used when the state of a component depends on changes of props. getDerivedStateFromProps(props ...
Read more >How to use componentDidUpdate in React
componentDidUpdate() is called after componentDidMount() and can be useful to perform some action when the state changes. componentDidUpdate() ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes - the bug was in eslint-plugin-react (you’d see the change on v16 as well, with a fully updated eslint-plugin-react). Specifically, gDSFP is both a static method and a lifecycle method, and the sorting logic was wrong.
See https://github.com/yannickcr/eslint-plugin-react/pull/1795 / https://github.com/yannickcr/eslint-plugin-react/issues/1793
Since
lifecycle
is primarily for instance methods, i think it would be in “statics”