作者:大大文人 | 来源:互联网 | 2023-02-05 10:09
我在反应组件的下一行收到警告
handleToggle: Function;
我正在使用eslint-plugin-react和Flow,我收到警告"handleToggle应该放在构造函数之后".这与规则react/sort-comp有关.我在.eslintrc.json上尝试了以下内容
"react/sort-comp": [1, {
"order": [
"static-methods",
"lifecycle",
"everything-else",
"render"
],
"groups": {
"lifecycle": [
"displayName",
"propTypes",
"contextTypes",
"childContextTypes",
"/^.*: Function$/",
"mixins",
"statics",
"defaultProps",
"state",
"constructor",
"getDefaultProps",
"getInitialState",
"getChildContext",
"componentWillMount",
"componentDidMount",
"componentWillReceiveProps",
"shouldComponentUpdate",
"componentWillUpdate",
"componentDidUpdate",
"componentWillUnmount"
]
}
}]
但是我无法修复警告.我希望构造函数之前的函数类型与其他类型定义相同.我怎样才能做到这一点?