Unexpected “Uncaught TypeError: XXX is not a constructor” errors with Babel and ES6

前端 未结 6 474
無奈伤痛
無奈伤痛 2020-12-29 19:04

I am giving a try to Webpack, and am giving a try to the instructions in this tutorial, give or take a few custom things.

This is simple code, really, but I\'m quite

6条回答
  •  爱一瞬间的悲伤
    2020-12-29 19:47

    What could I be missing?

    Babel assigns default exports to the default property. So if you use require to import ES6 modules, you need to access the default property:

    const Button = require('./Components/Button.js').default;
    

提交回复
热议问题