ali*_*ali 5 javascript reactjs eslint
如何避免ES7
箭头函数上的流型错误
handleSelectCategory = (e) => {
const { form } = this.state;
let newCategories = [];
if (form.categories.findIndex((c) => c.value === e.value) >= 0) {
newCategories = form.categories.filter((c) => c.value !== e.value);
} else {
newCategories = [...form.categories, e];
}
this.setState({
form: Object.assign({}, form, { categories: newCategories }),
});
};
Run Code Online (Sandbox Code Playgroud)
我收到警告
Expected parentheses around arrow function argument. (arrow-parens)
Run Code Online (Sandbox Code Playgroud)
当只有一个参数时,箭头函数的参数周围的括号在 ES6 中是可选的,但默认情况下 ESLint 会抱怨这一点。这是由箭头括号选项控制的。
更改此选项,或更改您的箭头函数以使用(c)
而不是c
用作参数列表。
归档时间: |
|
查看次数: |
18253 次 |
最近记录: |