Friday, 25 May 2018

Lifecycle methods of React component.

1- componentWillMount() – get called only once component initiated i.e. after constructure and right place to call setState in initial stage.

2- componentDidMount() – get called only once after component render first time.

3- componentWillReceiveProps() – Invoked as soon as the props are received from the parent class and before another render is called.

4- shouldComponentUpdate() – Returns true or false value based on certain conditions. If you want your component to update, return true else return false. By default, it returns false.

5- componentWillUpdate() – Called just before rendering takes place in the DOM.

6- componentDidUpdate() – Called immediately after rendering takes place.

7- componentWillUnmount() – get Called just before to component unmount from the DOM. It is used to unsubcribe the listner/event to avoid memory leak, etc.

No comments:

Post a Comment

What is diffing algorithm?

  React needs to use algorithms to find out how to efficiently update the UI to match the most recent tree. The diffing algorithms is genera...