Each component in React has a lifecycle with three phases:
There’s another phase called error handling. A component enters this phase upon encountering an error.
React exposes lifecycle methods that are called at different stages of the three phases.
In the list below, commonly used lifecycle methods are marked in bold. The rest of them exist for relatively rare use cases.
These methods are called in the following order when an instance of a component is being created and inserted into the DOM:
An update can be caused by changes to props or state. These methods are called in the following order when a component is being re-rendered:
This method is called when a component is being removed from the DOM:
These methods are called when there is an error occurs during rendering, in a lifecycle method, or in any child component’s constructor.
View all Courses