Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eslint error: Missing parentheses around multilines JSX react/jsx-wrap-multilines

I am using Material UI checkbox in my project. I used it the same way it's used in Material UI example: https://material-ui.com/components/checkboxes/ but eslint shows me this error:

error Missing parentheses around multilines JSX react/jsx-wrap-multilines

<FormControlLabel
  control={
    <Checkbox
      checked={data.default}
      value="default"
      onChange={(e) => {
        return setData({ ...data, default: e.target.checked });
      }}
    />
  }
  label="Make default"
/>

error is on the line 2 (control={....)

like image 663
Lukáš Smida Avatar asked Jun 25 '19 16:06

Lukáš Smida


1 Answers

Please, see the examples on the jsx-wrap-multilines rule page:

You can either disable that rule, or wrap any multiline React element into parentheses:

<FormControlLabel
  control={( // starting paren here
    <Checkbox
      checked={data.default}
      value="default"
      onChange={(e) => {
        return setData({ ...data, default: e.target.checked });
      }}
    />
  )} // ending paren here
  label="Make default"
/>
like image 195
Sulthan Avatar answered Oct 17 '22 22:10

Sulthan