Write react component from scratch : check my code it is not accepting

class MyComponent extends React.Component {
constructor(props) {
super(props);
}
render() {
return (

My First React Component!

); } };

ReactDOM.render(, document.getElementById(‘challange-node’));

Hi @pavandeore,

I believe you need to wrap whatever you return from your render function in a div tag

So for what you have here, you would add:

class MyComponent extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div>
  My First React Component!
</div>
); } };
ReactDOM.render(, document.getElementById(‘challange-node’));

You can also check your console for errors when you are having any issues and that may give you a bit more information when debugging.

Good luck & happy coding!

1 Like