3 ms·
That was roughly my guess. I asked because I ran into a specific edge case where this is finicky. AFAIK, arrow functions do (and should) have names if they're
by FLGMwt 9y ago
That was roughly my guess. I asked because I ran into a specific edge case where this is finicky.
AFAIK, arrow functions do (and should) have names if they're assigned to a variable.
const foo = () => {};
// undefined
foo.name
// "foo"
I ran into a specific bug where this doesn't work for the following case when using babel to target modern versions of node:
export const foo = () => {};
Note that's only when the declaration is part of an export (https://github.com/babel/babel/issues/7194 https://github.com/babel/babel/issues/7194).
The name works fine in the browser, but since jest/enzyme use node to run tests, I had issues with functional components (defined as arrow functions and immediately exported) were missing their names.
FWIW, this isn't an issue in Babel 7.