Whats really wrong with this code?

Tell us what’s happening:

Your code so far


// change code below this line

class MyComponent extends React.Component{
 
constructor(props){
    super(props);
}
render(){ 
 return(
     <div>
    <h1>My First React Component!</h1> 
    </div>      
   );
  };
};
ReactDOM.render(<MyComponent />, ('challenge-node'));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/write-a-react-component-from-scratch/

if this is a html tag then it needs to have a begin <> as well in HTML you alway start with <> and end with </> without a space

There are no child elements that is why I used < /> JSX… instead of the html <></>

On the last line, ReactDOM.render, you forgot to add document.getElementById before ('challenge-node')

so it should look like this:

ReactDOM.render(<MyComponent />, document.getElementById('challenge-node'));
4 Likes

I’m sure you got it, but just in case, if you still need more help you can also refer back to these challenges.

https://learn.freecodecamp.org/front-end-libraries/react/render-html-elements-to-the-dom/
https://learn.freecodecamp.org/front-end-libraries/react/render-a-class-component-to-the-dom

1 Like

I finally got it.Thanks