我試圖讓我的頭繞着這個錯誤整天。我正在嘗試將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