forlooptanzania/ride-my-way

What is the React Component Lifecycle like?

Opened this issue · 0 comments

In React, the component(s) always follow a cycle from the time of creation, when it is mounted on the DOM up to when it is unmounted and destroyed.

React provides hooks(methods) which are naturally called at each point in the lifecycle, these methods give us good control of what happens at the point it is invoked.

So simply a react hook is a method which is called automatically when a component is either rendered in the DOM, Updating the DOM or unmounting itself from the DOM. A good example of React lifecycle hook is componentDidMount, this method will be triggered when a Component's output is first inserted into DOM.