我试图让我的头绕着这个错误整天。我正在尝试将Flow添加到我的React应用程序中。React + Flow + eslint
我必须声明如下组件:对于MyComponentProps
type MyComponentProps = {
prop1: string,
prop2: string
};
// @flow
class MyComponent extends Component {
static defaultProps = {
prop1: 'a',
prop2: 'b'
};
handleOnClick: (value: string) => void;
props: MyComponentProps;
}
和类型现在,流量是报告没有错误。但是,当我尝试运行应用程序,我得到eslint
错误:
error 'defaultProps' is not defined no-undef
error 'handleOnClick' is not defined no-undef
error 'props' is not defined no-undef
我使用babel-eslint
和eslint-plugin-flowtype。 我已将flowtype/define-flow-type
规则添加到我的.eslintrc
文件中。以下是我的.eslintrc
文件的相关部分:
{
"parser": "babel-eslint",
"plugins": [
"flowtype",
"react"
],
"extends": [
"plugin:flowtype/recommended"
],
"rules": {
"flowtype/define-flow-type": 1,
"flowtype/use-flow-type" : 1,
"no-undef": 2,
"react/jsx-no-undef": 2
}}
我错过了什么?
你是否在声明或某个引用它们的地方获得了ESLint错误? – btmills
关于声明。 – Maggie
你有什么版本的eslint,babel-eslint和eslint-plugin-flowtype? – btmills