React Class Components
In Class base component has 2 features
1.State Management
2.Life Cycle Feature
Disadvantages
we cant not hooks in class base components
FORMATE OF CLASS COMPONENET
example:
import React,{Component} from ‘react’
import Display from ‘./Display’
export default class App extends Component {
state={
name:”React”,
}
render(){
return(
<div>
<center>
<Display data={this.state.name}/>
<br />
<button onClick={()=>this.setState({name:”Owner”})}>Change </button>
</center>
</div>
)
}
}
from above example declared a state varible and used
Props for class components
create js file with display
import React,{Component} from ‘react’
export default class Display extends Component {
render(){
return(
<div>
<h1>{this.props.data}</h1>
</div>
)
}
}
Life Cycle Of Components
3 types of components
1.Mounting
2.Updating
3.Un Mounting
1.Mounting
It is used to Putting Elements into DOM
mounting has 4 Buit-In Methods
1.Constructor()
2.getDerviedStateFromProps()
3.render()
4.ComponentDidMount()