3

enter image description here

What am I doing wrong? I have like three other async actions that have the same issue and can't fix it.

1201ProgramAlarm
  • 32,384
  • 7
  • 42
  • 56
Pedro Costa Neves
  • 463
  • 1
  • 5
  • 15
  • Just FYI its easier if you add your code in with your question rather than a screenshot – Mark May 27 '16 at 05:19
  • The rule is to prevent unnecessary nesting. The idea being that `x => y => x + y` is clearer than the nested alternative. – Jamie Dixon May 27 '16 at 07:31

2 Answers2

12

When you take a look at the Arrow Function Documentation

(param1, param2, …, paramN) => expression
// equivalent to:  => { return expression; }

the "Unexpected block statement surrounding arrow body" just means that you don't need a { return expression; } block for your arrow function here, as the arrow function does return by default.

const getOptions = () => (dispatch, getState) => {} 

is equivalent to

const getOptions = () => { return (dispatch, getState) => {} }

and therefore the block statement is unnecessary

larrydahooster
  • 4,114
  • 4
  • 40
  • 47
2

Not recommended:
You can always disable the arrow-body-style rule or configure it in a way that it doesn't give such errors.

Recommended:

const getOptions = () => ( dispatch, getState ) => {
    const {user} = getState();
    //rest of the code
}


This basically means that we don't have to write { return thing when we are only returning w/o doing anything else

Abhinav Singi
  • 3,379
  • 1
  • 20
  • 27