【发布时间】:2018-02-21 09:20:02
【问题描述】:
我是反应新手。我的应用程序运行正常,但添加 eslint(airbnb) 后,我的应用程序无法编译。
export default class HelloWorldComponent extends React.Component {
render() {
return (
<div>
<div>{this.props.message}</div>
<button onClick={this.props.helloWorldClick}>Hello
World</button>
</div>
)
}
helloWorldClick = () => {
console.log('here')
}
}
在 .eslintrc 文件上添加 { "parser": "babel-eslint" } 之前,它抛出了 eslint 错误
"[eslint] 解析错误:Unexpected token =" --在 helloWorldClick 箭头函数行。
添加解析器后,我没有任何 elsint 错误。但是运行应用程序时出现编译错误。
编译失败 ./src/component/HelloWorldComponent.js 第 18 行:'helloWorldClick' 未定义 no-undef
请告诉我如何解决此错误。
【问题讨论】:
标签: reactjs react-redux eslint eslint-config-airbnb