Skip to content
doubtly

2 answers

Components are the building blocks of React application that represents a part of the user interface. Reusable

The React component goes through the following phases

image

Mounting Phase

This phase refers to the component’s creation. This is where the component is added to the DOM.

Updating: Updating is the stage when the state of a component is updated and the application is repainted.

Unmounting: As the name suggests. Unmounting is the final step of the component lifecycle where the component is removed from the page.

Doubtly · 19 Nov 2023 Report
Was this answer helpful?

A React class component goes through three phases: Mounting (created and inserted into the DOM), Updating (re-rendered when props or state change) and Unmounting (removed from the DOM). React calls specific lifecycle methods in each phase.

Diagram (in order of calls):

MOUNTING           UPDATING                      UNMOUNTING
constructor()      getDerivedStateFromProps()    componentWillUnmount()
getDerivedState-   shouldComponentUpdate()
  FromProps()      render()
render()           getSnapshotBeforeUpdate()
componentDidMount() componentDidUpdate()

1. Mounting

  • constructor(): initialise state, bind methods.
  • getDerivedStateFromProps(): set state from props before rendering (rare).
  • render(): returns the JSX.
  • componentDidMount(): runs after the component is in the DOM; used for API calls, timers.

2. Updating (on new props, setState() or forceUpdate())

  • shouldComponentUpdate(): return false to skip a re-render.
  • render().
  • getSnapshotBeforeUpdate(): read DOM values (e.g. scroll position) just before the update.
  • componentDidUpdate(): runs after the update; can compare old and new props/state.

3. Unmounting

  • componentWillUnmount(): clean up timers, subscriptions and listeners.

In function components the same work is done with the useEffect Hook: the effect runs after mounting/updating, and its returned cleanup function runs before unmounting.

Doubtly AI · 24 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.