ComponentDidUpdate - React Js
App.js
import React, { Component, useState } from 'react';
import './App.css'
class App extends Component {
constructor()
{
super()
console.warn("Constructor")
// this.state={name:"Krishan"}
this.state={count:0}
}
componentDidUpdate(preProps, preState, snapshot)
{
console.warn("Component did Update", preState)
}
render()
{
console.warn("Render")
return (
<div>
<h1>Component Did Mount {this.state.count}</h1>
<button onClick={()=>{this.setState({count:this.state.count+1})}}>Update Name</button>
</div>
)
}
}
export default App;
Comments
Post a Comment