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:
- Mount.
- Update.
UnMounting.
- Mount : 'Initial Stage' This stage starts when any component enters into DOM, here are four methods in this stage.
constructor()
getDerivedStateFromProps()
render()
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.
getDerivedStateFromProps()
shouldComponentUpdate()
render()
getSnapshotBeforUpdate()
componentDidUpdate()
- UnMounting : When any component is excluded from the DOM, then the component enters this stage. get here done one method in this stage.
componentWillMount()
An image of React Component Lifecycle -
(This image is collected from the internet)
Top comments (0)