我一整天都在试着忘掉这个错误。我正在尝试将流添加到我的React应用程序。
我有一个这样声明的组件:
// @flow
class MyComponent extends Component {
static defaultProps = {
prop1: 'a',
prop2: 'b'
};
handleOnClick: (value: string) => void;
props: MyComponentProps;
}和MyComponentProps的类型
type MyComponentProps = {
prop1: string,
prop2: string
};现在,Flow没有报告错误。但是当我尝试运行这个应用程序时,我得到了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。我已经在.eslintrc文件中添加了flowtype/define-flow-type规则。下面是我的.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
}}我遗漏了什么?
https://stackoverflow.com/questions/44507539
复制相似问题