Skip to main content

Posts

Showing posts with the label shouldComponentUpdate method

React shouldComponentUpdate Method | Components Lifecycle

The shouldComponentUpdate Method  - The  shouldComponentUpdate () method is invoked before rendering (render method) when new props or state are being received. The defaults value is true. The  shouldComponentUpdate () method is not called for the initial render or when forceUpdate() is used. Explore to Understand   -  React Lifecycle Components As an Example  1– When shouldComponentUpdate value is fale?  My Color is  red  after click on Change color. import   React   from   'react' ; import   ReactDOM   from   'react-dom' ; class   Header   extends   React . Component  {    constructor ( props ) {      super ( props );      this . state  = { color:   "red" };   }    shouldComponentUpdate () {      return   false ;  ...