exporting multiple modules in react.js

前端 未结 2 1758
半阙折子戏
半阙折子戏 2020-12-13 03:49

New to react.js and trying to following tutorial. Unfortunately the code given in the page didn\'t work. webpack complained

ERROR in ./App.jsx
Module build         


        
2条回答
  •  清歌不尽
    2020-12-13 04:20

    When you

    import App from './App.jsx';
    

    That means it will import whatever you export default. You can rename App class inside App.jsx to whatever you want as long as you export default it will work but you can only have one export default.

    So you only need to export default App and you don't need to export the rest.

    If you still want to export the rest of the components, you will need named export.

    https://developer.mozilla.org/en/docs/web/javascript/reference/statements/export

提交回复
热议问题