NA +91-8727899942 thecoderjob@gmail.com

CHAPTER - 21

Life cycle (class component)

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>

      </>

    );

  }

}

Chapter 20

Life cycle (class component)

Previous chapter

Chapter 22

Life cycle (class component)

Next chapter

Get In Touch

NA

thecoderjob@gmail.com

+91-8727899942

Popular Links

© www.thecoderjob.com. All Rights Reserved.               Designed by HTML Codex