NA +91-8727899942 thecoderjob@gmail.com

CHAPTER - 23

Life cycle (class component)

shouldComponentUpdate

It execute with condition.

Eg:

class App extends React.Component {

  constructor() {

    super();

    this.state={

      count:0

    }

  }

  shouldComponentUpdate(){

   if(this.state.count<5){

     return true;

   }

  }

  render() {

    return (

      <>

        <button onClick={()=>this.setState({count:this.state.count+1})}>Update Counter</button>

      </>

    );

  }

}

  }

}

Chapter 22

Life cycle (class component)

Previous chapter

Chapter 24

23. 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