From the docs
Omitting the curly braces implies using an expression as the MDN documentations says
Basic Syntax
(param1, param2, …, paramN) => { statements } (param1, param2, …,
paramN) => expression // equivalent to: (param1, param2, …, paramN) =>
{ return expression; }
// Parentheses are optional when there's only one parameter name:
(singleParam) => { statements } singleParam => { statements }
singleParam => expression
// The parameter list for a function with no parameters should be
written with a pair of parentheses. () => { statements }
Expressions versus statements in Javascript
Explanations
So basically the following should work as callSomething()
is an expression
const myFunction = error => callSomething(error)
With statements not being expressions (such as multiple expressions for exemple) the curly braces are mandatory
Example 1
const myFunction = error => {
// other statements such as
console.error(error);
callSomehting(error);
});
Example 2
throw error
is a statement but not an expression!
const myFunction = error => {
throw error;
});