Each component in React has a life cycle which we can monitor and manipulate during its three main phases :
- Mounting - when component is loaded
- Updating - when component is updated
- Unmounting - when component is removed
To understand above React life cycle, we need to understand human life cycle. Human has three main phases :
- Birth
- Growth
- Death
Similarly, each React Life Cycle phase have different methods like : constructor(), render(), componentDidMount(), etc.
The above life cycle methods works in Class Components only. To use Life cycle in Functional Component, we use Hooks.
Comments
Post a Comment