React Component Lifecycle: Mounting, Updating & Unmounting

Every React component undergoes a continuous lifecycle from its creation in memory to its destruction when the user navigates away. Understanding lifecycle phases is one of the most frequently asked questions in university BCA/CS exams and technical job interviews.

The 3 Lifecycle Phases

Phase Class Lifecycle Methods Modern Functional Hooks Equivalent
1. Mounting
(Born into DOM)
• constructor()
• render()
• componentDidMount()
• Function body executes
• Return JSX
• useEffect(() => { ... }, [])
2. Updating
(Props/State change)
• shouldComponentUpdate()
• render()
• componentDidUpdate()
• React.memo (skips render)
• useEffect(() => { ... }, [dependencies])
3. Unmounting
(Removed from DOM)
• componentWillUnmount() • useEffect(() => { return () => cleanup(); }, [])

Class Lifecycle Example (College Syllabus Reference)

import React, { Component } from 'react';

class LifecycleLogger extends Component {
  componentDidMount() {
    console.log('1. componentDidMount: DOM is ready; start API calls.');
  }

  componentDidUpdate(prevProps, prevState) {
    console.log('2. componentDidUpdate: Component received new data.');
  }

  componentWillUnmount() {
    console.log('3. componentWillUnmount: Component about to be destroyed.');
  }

  render() {
    return <h3>Component Lifecycle in Action</h3>;
  }
}

Next Step: Context API & useContext

Now let us solve prop drilling by broadcasting global state in React Context API & useContext.

Explore Related React JS Tutorials

Accelerate your React mastery by studying these tightly connected core tutorials:

useEffect Hook Replacement →

Modern hooks equivalent for class lifecycle methods.

componentDidCatch & Errors →

Handling uncaught runtime exceptions in classes.

Render & Commit Phases →

When lifecycle methods execute during reconciliation.

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit

You may also like this!