Write a React Component from Scratch #pleasehelp

Tell us what’s happening:
I really don’t know what I’m doing wrong in here. Please help me. Thank you.

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,document.getElementById('challenge-node'))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

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

When you are rendering a component to the DOM using ReactDOM.render, you need to use wrap it around with tags and make it self closing.

It should be

<MyComponent />

2 Likes