简体   繁体   English

导出默认不工作webpack,reactjs

[英]export default not working webpack, reactjs

I'm new to webpack, I'm starting to build an app using webpack and react 15, however it's like the export default is not working properly because I got an error as the App component is not found: 我是webpack的新手,我开始使用webpack构建一个应用程序并做出反应15但是它就像导出默认设置不正常,因为我收到了一个错误,因为找不到App组件:

 5:9  App not found in './components/App'  import/named

Below the code of my index.js: 在我的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')
);

and the code of my App.js placed under components folder: 并将我的App.js的代码放在components文件夹下:

import React, { PropTypes } from 'react';


const App = (props) => {
  return (
    <div>
      {props.children}
    </div>
  );
};

App.propTypes = {
  children: PropTypes.element
};

export default App;

Can anyone see the problem? 有谁能看到这个问题? Looks like this type of export is not supported and I have to enable something? 看起来这种类型的导出不受支持,我必须启用一些东西? Any help is appreciatted!! 任何帮助都很高兴!!

Omit the curly braces: 省略花括号:

import App from './components/App';

That's the trick with default , see . 这是default的技巧, 请参阅

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM