DEV Community

NEYAZ NAFIZ
NEYAZ NAFIZ

Posted on • Edited on

1

React component lifecycle.

In React, a component's lifecycle refers to the events that occur from initialization to destruction. React components undergo three main phases: Mounting, Updating, and Unmounting. Each phase has a set of lifecycle methods that you can override to perform actions at specific points in the component's life.

Basically, the React Component lifecycle has 3 stages:

  1. Mount.
  2. Update.
  3. UnMounting.

    • Mount : 'Initial Stage' This stage starts when any component enters into DOM, here are four methods in this stage.
  4. constructor()

  5. getDerivedStateFromProps()

  6. render()

  7. componentDidMount()

    • Updating : When any changes of props or state make changes in the component, then the component enters this stage. here are five methods in this stage.
  8. getDerivedStateFromProps()

  9. shouldComponentUpdate()

  10. render()

  11. getSnapshotBeforUpdate()

  12. componentDidUpdate()

    • UnMounting : When any component is excluded from the DOM, then the component enters this stage. get here done one method in this stage.
  13. componentWillMount()

An image of React Component Lifecycle -

Image description
(This image is collected from the internet)


AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay