React Class Component

RMAG news
import React from “react”;

class App extends React.Component{
constructor(){
super();
this.state = {
};
};
render(){
return(
<>
<h1>Hello World</h1>
<h1>Hi</h1>
</>
);
};
};

export default App;

Points to remember:

constructor is a function so syntax -> constructor(){}. Same for render(){}. And all other lifeCycle methods are called the similarly.
render should return() something which is JSX.

Leave a Reply

Your email address will not be published. Required fields are marked *