我有一个文件MainContainer.jsx
,其中我已编写此代码:
import React, { Component } from 'react'
/**
* Main Container, this will pass on all the Redux Store,
* Router references to child elements.
*/
class MainContainer extends Component {
/**
* React Lifecycle Method: Renders the data
*
* @return {DOM} Main container DOM.
*/
render() {
return (
<p>Hello world</p>
)
}
}
export default MainContainer
这是文件的地址:app/containers/Main/MainContainer.jsx
我正试图通过export
文件container
index.js
目录中的所有内容。以下是文件的内容:
export MainContainer from './Main/MainContainer'
我已为webpack alias
目录设置containers
为$CONTAINERS
。现在我尝试像这样导入MainContainer
:
import MainContainer from '$CONTAINERS' // no need to pass the MainContainer full path, as it's being exported from index.js
现在我在index.js上遇到了构建错误:
@ ./app/index.jsx 13:14-39
@ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server babel-polyfill ./app ./app/styles/main.css
ERROR in ./app/containers/index.js
Module build failed: SyntaxError: Unexpected token, expected { (1:7)
> 1 | export MainContainer from './Main/MainContainer'
| ^
2 |
@ ./app/config/routes.jsx 21:19-41
@ ./app/index.jsx
有人知道我在这里错过了什么......