export default const foo = {
get() {}
};
Unexpected token (1:15)
But
const foo = {
get() {}
};
export default foo;
All fine.
export default takes an expression, not a statement. You can't use var, let, or const
Because it confused me, you _can_ do:
export default 3
or
export default {
get() {}
}
etc
Yeah, this is a bit annoying as in react for instance if you define a stateless component and you want it to show with a nice name you had to do
const MyComponent = () => (<div>Foo</div>)
export default MyComponent
It'd be much nicer to be able to do
export default const MyComponent = () => (<div>Foo</div>)
If you want to use the second one you of course can't specify const so you end up seeing <StatelessComponent /> all throughout your react code.
Most helpful comment
export defaulttakes an expression, not a statement. You can't usevar,let, orconst