Uncaught Error: Minified React error #130

前端 未结 2 1908
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-21 21:58

So here is what my code looks like

---------index.js-----

var React =require(\'react\');
var ReactDOM =require(\'react-dom\');
var App=require(\'../compo         


        
相关标签:
2条回答
  • 2021-01-21 22:20

    In the file index.js, you should change your code like this:

    var App = require('../components/App').default;
    

    or use import

    import App from '../components/App';
    

    I recommend using a unified usage. You can import/export or module.exports/require.

    0 讨论(0)
  • 2021-01-21 22:23

    You're mixing up require, and import / export.

    Since you're running webpack, all of your React code (and anything that gets transpiled by babel via webpack) should stick to using import/export. require should only be used in places like js that's directly run by node.

    In your index.js, change all the requires to imports and see if that helps.

    0 讨论(0)
提交回复
热议问题