React Lifecycle methods explained

Photo by XPS on Unsplash

In React components have many lifecycle methods that we can use in different phases of the component existence. The lifecycle of a component is consisted of three main phases: Mounting, Updating and Unmounting. Lets look at each one of these phases and the methods associated with them.

Mounting

Constructor()

Render()

componentDidMount()

Updating

componentDidUpdate()

Unmounting

componentWillUnmount()

I also want to mention that these methods are only accessible in class components. In functional components, however, you can use hooks to achieve the same result.

Wrap Up

Thanks for reading :)

I write about topics related to web development.