'React component won't render
I am doing freecodecamp and I am geting following error: Uncaught TypeError: Super expression must either be null or a function I can't figure out where my mistake is. Here is code:
class MyComponent extends React.component{
constructor(props){
super(props);
};
render(){
return(
<div>
<h1>My First React Component!</h1>
</div>
);
};
};
ReactDOM.render(<MyComponent />,document.getElementById('challenge-node'));
Solution 1:[1]
I believe it is because of a simple typo in your code.
You have inputted React.component where is should be React.Component. I rectified that and the code works now.
class App extends React.Component {
render() {
return (
<div>
<h1>My First React Component!</h1>
</div>
);
}
}
ReactDOM.render(<App />, document.getElementById("challenge-node"));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
