Rasmus Nørskov
Rasmus Nørskov

Reputation: 474

babel wrongly transpiles export default function

I'am attempting to create a stateless functional component in react, but it looks like babel is having some trouble transpiling. The snippet export default AppLayout = () => {}; is transpiled to exports.default = AppLayout = function AppLayout() {}; which gives the following error Uncaught ReferenceError: AppLayout is not defined.

I am running babel with the following presets stage-0, es2015 and react. I have used this syntax in meteor, so I am guessing its a module I am missing.

Upvotes: 2

Views: 232

Answers (1)

Vincent Taing
Vincent Taing

Reputation: 3334

This should also work

const MyComponent = () => <div>Hi</div>
export default MyComponent;

or a one liner

export default () => <div>Hi</div>

Upvotes: 3

Related Questions