×

Html & Html5

The World's best Software Development Study Portal

Components

In the Components, we will understand the types and how to reuse of Components. There are 2 type of Components in react js
1. Stateless Functional Components
2. Statefull Class Components

Stateless Functional Components

Javascript Functions
import React from 'react';

import ReactDOM from 'react-dom';

function New(){


return<h2>Hello</h2>

}

export default New;

Stateful Class Components

Class extending components class
Render method returning html
class Statefull extends React.Component{
constructor(props){
super(props);
this.state={
name:"Deepak kumar"
}
}
render(){
return(
<div>
<h1>{this.state.name}</h1>
</div>
);
};
};



Components Summary


1. Components are the parts of user interface

2. Components are reusable can be nested inside the others.