如何避免流量类型错误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 }),
});
};
我收到警告
Expected parentheses around arrow function argument. (arrow-parens)
当只有一个参数时,箭头函数参数周围的括号在 ES6 中是可选的,但 ESLint 默认情况下会抱怨这一点。这是由箭头括号 https://eslint.org/docs/rules/arrow-parens option.
更改此选项,或更改要使用的箭头函数(c)
代替c
如参数列表所示。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)