react: Uncaught TypeError: Super expression must either be null or a function, not undefined while importing react and react-dom
This are my dependencies and there version ( if it helps )
"dependencies": {
"react": "^16.3.1",
"react-dom": "^16.3.1",
"webpack": "^2.1.0-beta.25"
},
I have the most simplest code for the hello world using react component
import React from 'react';
import ReactDOM from 'react-dom';
class Hello extends React.Component{
render(){
return (
<h1>hello world</h1>
)
}
}
ReactDOM.render(
<Hello />,
document.getElementById('root')
)
```
`
using bundle.js in the html script to bundle up everything
**getting error**
`Uncaught TypeError: Super expression must either be null or a function, not undefined
at _inherits (script.js:2)
at bundle.js:7830
at Object.<anonymous> (script.js:11)
at __webpack_require__ (bootstrap d328d05e6065876b9d70:19)
at bootstrap d328d05e6065876b9d70:63
at bootstrap d328d05e6065876b9d70:63`
thanks in advance
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 20 (1 by maintainers)
@anikethsaha It blames to
inline
option in UglifyJS. You can setinline: false
like this:It’s work for me.
If you changed that but it didn’t help then you didn’t recompile the code. When you use webpack directly you need to recompile your code after changing it.
Again, I encourage you to try a tool specifically designed for people new to React (I posted a link above: https://reactjs.org/docs/add-react-to-a-new-app.html). It will automatically recompile your code as you work on it. It is hard to learn both React and how to use build tooling at the same time so I think it might help if you don’t use webpack directly until you’re more comfortable with a higher level tool like Create React App.