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

Popular posts from this blog

Send Data Child to Parent Component - React Js

Hide , Show and Toggle in ReactJs

Importance Of Web Content In SEO.