When I try to export my component my editor show me an error export declaration statement expected
here is my code:
export Header from './Header/Header';
but if I do this:
export {default as Header} from './Header/Header';
it doesn't show any error.
my Header.js
export default class Header extends React.Component {
//code
}
I'm following this example https://github.com/erikras/react-redux-universal-hot-example/blob/master/src/components/index.js
My component folder structure and export method same like those link.
Any solution?
Any solution?
export Header from './Header/Header';
is not valid syntax, however there exists a proposal to support it.
The repository you linked to configured babel to support this proposed feature by using the stage-0
preset:
{
"presets": ["react", "es2015", "stage-0"],
...
}
stage-0
includes stage-1
which contains the transform-export-extensions
plugin that implements this feature.
But to be clear, you don't have to use this experimental feature.
export {default as Header} from './Header/Header';
has the same effect and is standard ES6.
Try
export default from './Header/Header';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With