Explain the lifecycle methods of components

  • getInitialState(): This is executed before the creation of the component.
  • componentDidMount(): Is executed when the component gets rendered and placed on the DOM.
  • shouldComponentUpdate(): Is invoked when a component determines changes to the DOM and returns a “true” or “false” value based on certain conditions.
  • componentDidUpdate(): Is invoked immediately after rendering takes place.
  • componentWillUnmount(): Is invoked immediately before a component is destroyed and unmounted permanently.