componentDidUpdate
It execute, When update state and props.
Eg:
class App extends React.Component {
constructor(){
super();
this.state={name:"xyz"}
}
componentDidUpdate(previous, next){
console.warn(“It execute, When update state and props”)
}
render()
{
return (
<>
<h1>Component Did Mount {this.state.name}</h1>
<button onClick={()=>this.setState({name:"Sidhu"})}>Update</button>
</>
);
}
}
© www.thecoderjob.com. All Rights Reserved. Designed by HTML Codex