Closed
Description
static getDerivedStateFromProps() {}
constructor(props) {}
state = {};
Above code reports
getDerivedStateFromProps should be placed after state
So I change the code
constructor(props) {}
state = {};
static getDerivedStateFromProps() {}
getDerivedStateFromProps should be placed before constructor
Also, the state property must be placed after the constructor. Something doesn't make sense here.
'error',
{
order: ['static-methods', 'lifecycle', 'everything-else', 'render'],
groups: {
lifecycle: [
'displayName',
'propTypes',
'contextTypes',
'childContextTypes',
'mixins',
'statics',
'defaultProps',
'constructor',
'getDefaultProps',
'state',
'getInitialState',
'getChildContext',
'getDerivedStateFromProps',
'componentWillMount',
'UNSAFE_componentWillMount',
'componentDidMount',
'componentWillReceiveProps',
'UNSAFE_componentWillReceiveProps',
'shouldComponentUpdate',
'componentWillUpdate',
'UNSAFE_componentWillUpdate',
'getSnapshotBeforeUpdate',
'componentDidUpdate',
'componentDidCatch',
'componentWillUnmount'
]
}
}
]```