0
votes

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'));
2
you have an extra };Dimitar Veljanovski
I don't think that's it. Last } closes class and one before that closes render.narutouzumaki 99

2 Answers

1
votes

it should be React.Component and not React.component

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'));
1
votes

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("container"));