【发布时间】:2016-12-27 15:29:08
【问题描述】:
我是 webpack 的新手,我开始使用 webpack 和 react 15 构建一个应用程序,但是好像导出默认值无法正常工作,因为我收到了一个错误,因为找不到 App 组件:
5:9 App not found in './components/App' import/named
在我的 index.js 的代码下面:
import React from 'react';
import ReactDOM from 'react-dom';
import {Router,Route,IndexRoute,browserHistory} from 'react-router';
import { Provider } from 'react-redux';
import {App} from './components/App';
import {HomePage} from './components/HomePage';
import configureStore from './store/configureStore.js';
import { syncHistoryWithStore } from 'react-router-redux';
const store = configureStore();
const history = syncHistoryWithStore(browserHistory, store);
ReactDOM.render(
<Provider store={store}>
<Router history={history}>
<Route path="/" component={App}>
<IndexRoute component={HomePage}/>
</Route>
</Router>
</Provider>,
document.getElementById('app')
);
以及我的 App.js 的代码放在 components 文件夹下:
import React, { PropTypes } from 'react';
const App = (props) => {
return (
<div>
{props.children}
</div>
);
};
App.propTypes = {
children: PropTypes.element
};
export default App;
任何人都可以看到问题吗?看起来不支持这种类型的导出,我必须启用一些东西? 任何帮助表示赞赏!
【问题讨论】:
标签: javascript reactjs ecmascript-6 webpack