如何避免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)