admin管理员组文章数量:1344686
When I try to export my ponent 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 .js
My ponent folder structure and export method same like those link.
Any solution?
When I try to export my ponent 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./erikras/react-redux-universal-hot-example/blob/master/src/ponents/index.js
My ponent folder structure and export method same like those link.
Any solution?
Share Improve this question asked Apr 19, 2017 at 4:13 ssuhatssuhat 7,66620 gold badges67 silver badges123 bronze badges 2-
export {default as Header} from './Header/Header';
looks right to me. What's the issue with that? – Felix Kling Commented Apr 19, 2017 at 4:37 - @Felix Kling no issues. I'm curious why at the link I post, there's no issue – ssuhat Commented Apr 19, 2017 at 4:40
2 Answers
Reset to default 8Any 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';
本文标签: javascriptReact export declaration statement expectedStack Overflow
版权声明:本文标题:javascript - React export declaration statement expected - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743738980a2530540.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论