Expected parentheses around arrow function argument. (arrow-parens)

Viewed 26654

How to avoid Flow-type error on an ES7 arrow function

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 }),
  });
};

I receive the warning

Expected parentheses around arrow function argument. (arrow-parens)
1 Answers

Parentheses around the parameter to an arrow function are optional in ES6 when there's only one argument, but ESLint complains about this by default. This is controlled by the arrow-parens option.

Either change this option, or change your arrow functions to use (c) instead of c as the parameter lists.

Related