š React Lifecycle ā Explained Simply
Hello there! You know React, youāve probably built several apps using it. But sometimes, when someone asks āWhat is the React Lifecycle?ā, itās hard to explain it in simple terms. So letās break it down together and understand how to explain it in a way that even a beginner can follow.

What is Lifecycle in React?
Letās say you have components āĀ X,Ā Y, andĀ Z. React takes these components and turns them into JSX. These JSX expressions ultimately produce what the user sees in the browser.
But what happensĀ between writing JSX and seeing output on the screen?
Thatās what we call theĀ React LifecycleĀ ā the journey a component goes through from start to end.

1. Mount Phase (Initial Render)
This is when a component first appears on the screen.
š¹ What Happens:
- ReactĀ mountsĀ the component ā meaning it runs theĀ entire function bodyĀ of the component.
- ItĀ initializesĀ all variables and hooks(
useState, useMemo,Constants (const,Ālet,Āvar) - JSX is returned.
- React passes this JSX to theĀ Virtual DOMĀ ā a copy of the actual DOM that exists in memory.
- The Virtual DOM acts like aĀ middlewareĀ ā it checks for differences (diffing) between itself and the actual DOM.
- Once differences are found, it updates theĀ Real DOMĀ (what the user sees in the browser).
- The user finally sees the output on the screen.
šø After that:
- If thereāsĀ asynchronous codeĀ (like insideĀ
useEffect), ReactĀ schedulesĀ it to runĀ afterĀ the component has been rendered in the browser. - So effects like data fetching or event listeners happenĀ after the browser shows the component.
ā Ā
useEffect(() => { ... }, [])Ā runsĀ afterĀ the component is mounted.
# Between Two Renders
Very Important:
Before running the next render, React will check if you have aĀuseEffectĀ with aĀ cleanup function, and it will run that cleanup first.
2. Update Phase (Re-render)
Once the component is on the screen, it may need to update
š¹ What Triggers an Update:
- A user interaction
- A change inĀ
props - A change inĀ
state - Timers, API calls, etc.
š¹ What Happens:
- React re-runs the component function āĀ same as in the mount phase.
- ItĀ recomputes values, updates state, and checks if any state or propsĀ changed.
- JSX is returned again.
- Virtual DOM compares the new JSX with the previous version and figures out what changed.
- React updates only the changed parts in the Real DOM (efficient rendering).
- Browser reflects the updated UI.
šø In between renders:
- Cleanup functionsĀ (fromĀ
useEffectĀ if you have define clean up function) are run before the next render. - After the update, anyĀ scheduled hooks or async codeĀ run again.
ā Think of update phase as: Re-run ā Diff ā Update DOM ā Re-runĀ
useEffectĀ ā Cleanup if needed
3. Unmount Phase (Exit)
This phase occurs when a component isĀ removed from the screenĀ ā for example, when a user navigates away or the component is no longer needed.
š¹ What Happens:
- ReactĀ releases all values from memory (
useState, useMemo,Variables likeĀconst,Ālet, etc) - If you have a cleanup function inĀ
useEffect, it runs now. - Virtual DOM prepares the change.
- ReactĀ removes the component from the Real DOM.
- Browser no longer shows it.
ā Ā
useEffect(() => { return () => { ... } }, [])Ā handles cleanup on unmount.
š Server-Side Lifecycle (SSR in React)
Until now, we talked about React on theĀ client-sideĀ (i.e., the browser).
But thereās alsoĀ server-side renderingĀ (SSR), like inĀ Next.jsĀ or custom setups.
š¹ What Happens on the Server:
- No hooks likeĀ
useEffectĀ orĀuseStateĀ run on the server. - React just returnsĀ JSX, which is converted toĀ HTML.
- This HTML is sent to the browser.
- Browser displays the contentĀ fasterĀ because itās already rendered.
ā ļø There isĀ no hooksĀ likeĀ
useEffectĀ on the server.
Thatās whyĀ server-side components are faster, but you lose dynamic behavior during initial load.
šø Bonus Details:
- Server componentsĀ can be async.
- You can perform tasks like:
- Fetching data from a database
- Calling APIs
- Running server-side logic
š What if data changes on the server?
IfĀ data changes on the server, aĀ server-side functionĀ will be triggered again. That function will:
- Fetch or reprocess the updated data
- Generate new JSX with the updated data
- JSX is then converted to HTML again
- The new HTML is sent to the client/browser
ā This is like āre-renderingā on theĀ server, but not the same as client-side re-renders ā itāsĀ regenerating the page HTMLĀ based on fresh data.
ā ļø Reminder:
- On the server, there isĀ no lifecycleĀ likeĀ
useEffect. - But we canĀ respond to data changesĀ by re-running the server function, which returns fresh JSX ā HTML.