小编nmu*_*zsi的帖子

如何使用eslint-plugin-react来修复由Flow Function Types引起的警告?

我在反应组件的下一行收到警告

handleToggle: Function;
Run Code Online (Sandbox Code Playgroud)

我正在使用eslint-plugin-reactFlow,我收到警告"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"
    ]
  }
}]
Run Code Online (Sandbox Code Playgroud)

但是我无法修复警告.我希望构造函数之前的函数类型与其他类型定义相同.我怎样才能做到这一点?

reactjs eslint flowtype

5
推荐指数
1
解决办法
588
查看次数

标签 统计

eslint ×1

flowtype ×1

reactjs ×1