DEV Community

Fatima Alam
Fatima Alam

Posted on

React Class Component

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;
Enter fullscreen mode Exit fullscreen mode

Points to remember:

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

Top comments (0)