React Lifecycle

  1. constructor
    One-time setup, assignments.Do not do data-loading inside the constructor, instead do it in componentDidMount.
  2. render
    Return JSX, nothing else!
  3. componentDidMount
    Place for data-loading, api requests etc.
  4. componentDidUpdate
    Place to do more data-loading when state/props change. Render-method will be called just before this method.
  5. componentWillUnmount
    Place for cleanup

 

 

 

Rarely used lifecycle methods:

shouldComponentUpdate

getDerivedStateFromProps

getSnapshosBeforeUpdate

Add your comment