导出默认不工作webpack,reactjs

时间:2016-08-20 16:43:53

标签: javascript reactjs ecmascript-6 webpack

我是webpack的新手,我开始使用webpack构建应用程序并做出反应15但是它就像导出默认设置无法正常工作因为我收到错误的应用程序找不到组件:

 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;

有人能看到问题吗?看起来这种类型的导出不受支持,我必须启用一些东西? 任何帮助都很高兴!!

1 个答案:

答案 0 :(得分:19)

省略花括号:

import App from './components/App';

这是defaultsee的诀窍。