componentDidUpdate()
class LifeCycle extends Component {
constructor(){
super()
console.log("constructor start")
this.state = {
count : 0
}
}
getData = async() =>{
const data = await fetch("https://jsonplaceholder.typicode.com/users")
const result = await data.json()
console.log(result)
}
componentDidMount(){
this.getData()
console.log("component life cycle start")
}
componentDidUpdate(){
console.log("component state is update")
}
increment = () => {
this.setState({
count : this.state + 1
}
}
render(){
console.log("render start")
return (
<div>
<h1>Count - {count}</h1>
<button onClick={this.increment}> Increment </button>
</div>
)
}
}Last updated