componentDidMount
Constructor, render and after componentDidMount execute
Eg:
class App extends React.Component {
constructor(){
super();
this.state={name:"xyz"}
}
componentDidMount(){
console.warn(“It execute when all html load, alway use api in this area.”)
}
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