React - How to export a pure stateless component
ES6 doesn't allow export default const
. You must declare the constant first then export it:
const Header = () => {
return <pre>Header</pre>
};
export default Header;
This constraint exists to avoid writting export default a, b, c;
that is forbidden: only one variable can be exported as default
Just as a side note. You could technically export default
without declaring a variable first.
export default () => (
<pre>Header</pre>
)