2

Im using the shortened ES6 arrow function notation to write my function body like this

const funcName = (...args) => something

I'm not even using a single curly bracket since my function body has just 1 return statement.

But say I want to return an object from this function, I would have to do:

const funcName = (...args) => {key:val}

The problem here is babel is assuming that the stuff inside the curly brackets is a function body - not an object - how to make it think that it is indeed an object??

Probosckie
  • 1,585
  • 4
  • 25
  • 40

1 Answers1

5

Embrace it with brackets

const funcName = (...args) => ({key:val})
smnbbrv
  • 23,502
  • 9
  • 78
  • 109