
If you've written even a small React app, you've probably wondered:
"Why did my component render again?"
"Why is React re-running my function?"
"What exactly triggers a re-render?"
"Does every state update cause a re-render?"
"Should I worry about unnecessary renders?"
These questions are extremely common even experienced developers revisit them.
Rendering and re-rendering are core behaviors of React. Once you understand them deeply, React becomes predictable, easy, and logical. This blog explains rendering the way a senior developer would explain it to a beginner humanized, simple, and without code.
Rendering is the process where React takes your component's output (JSX) and figures out what the UI should look like.
In simple words:
Rendering is React's way of describing the UI.
During rendering, React:
runs your component function
evaluates your JSX
builds a virtual representation of the UI
prepares the blueprint for what to show on the screen
Rendering does NOT mean updating the real screen immediately.
Rendering simply creates the plan.
The actual update to the browser happens in the commit phase, not during the render.
Re-rendering means React has decided that something changed and needs to re-run your component to see what the updated UI should look like.
Think of it like this:
If your component were a recipe, re-rendering is React re-reading the recipe to see if anything has changed.
If the ingredients (state, props, context) change the recipe must be re-read.
React re-renders components when:
A component's state changes
If you update state in a component, React re-renders that component.
A component receives new props
If the parent sends new data, the child re-renders.
A parent component re-renders
When a parent re-renders, all children re-render by default.
A context value used by the component changes
Any component consuming context will re-render when the context updates.
A hook dependency changes
For example, effects re-run when dependencies change.
Strict Mode (dev only) intentionally re-renders components twice
This helps you catch bugs and side-effect issues.
These are the fundamental triggers.
Beginners often panic:
"My component re-rendered! This is bad!"
No.
Rendering is NORMAL.
Re-rendering is NORMAL.
React is designed to re-render efficiently.
Instead of avoiding re-renders completely, the real skill is understanding them and optimizing only when necessary.
React's UI update process has two distinct phases:
React calls your components
Builds Virtual DOM
Compares with previous virtual state
Identifies what needs updating
This phase is pure, interruptible, and does not touch the real DOM.
React updates the real DOM
Applies changes to actual elements
Browser paints the final UI
This is the phase that the user sees.
Render = Thinking
Commit = Doing
React "thinks" first, then "does."
React uses a lightweight in-memory representation of the UI called:
The Virtual DOM
When your component renders, React:
Creates a new Virtual DOM snapshot
Compares it with the old one (diffing)
Finds exactly what has changed
Updates only those parts in the real DOM
Without Virtual DOM, re-rendering would be extremely slow.
When a component renders, React:
Calls the component function
Evaluates all variables inside it
Evaluates JSX
Builds a virtual UI description
Prepares a list of DOM mutations
Applies changes in the commit phase
Rendering does not directly update the screen React uses this process to stay fast and predictable.
Even if only one part of the UI React changes, React may re-render entire branches of the component tree.
Why?
Because rendering is cheap.
Real DOM updates are expensive, but Virtual DOM computations are fast.
React prefers:
frequent renders
minimal DOM updates
This is why React stays fast even in large apps.
If you remember only one section, remember this:
React re-renders a component when:
State belongs to a component. If state updates → component re-renders.
If a parent sends new props → child re-renders.
If a component consumes context → updates trigger re-render.
Every re-render in React comes from one of these three.
Imagine you're building a counter.
When the user clicks "+1," state changes.
A changed state = component re-renders.
During re-render:
React calls the component again
JSX is evaluated again
The Virtual DOM updates
React updates only the number on the screen
The whole component re-runs, even if only one number changed.
Imagine you have:
A parent component
A child component that displays a name
If the parent sends a new name through props:
→ child must re-render
→ React re-runs the child component
→ UI updates accordingly
This is how React ensures the UI always stays in sync with the data.
When a parent re-renders:
All of its children re-render
Even if their props didn't change
This is normal and expected.
Why?
Because React needs to re-run children to ensure consistency.
React re-renders components whose state or props changed NOT just the small part of the UI.
React does NOT re-render individual elements.
React re-renders entire components then updates the UI efficiently.
Rendering ≠ DOM update.
React compares the Virtual DOM first.
If nothing changed, it updates nothing on the screen.
This is React's power.
React re-renders:
often
aggressively
intentionally
And that's okay.
React is optimized for this behavior.
You only need to optimize re-renders when:
performance drops
component trees get huge
repeated renders slow down UI
90% of the time, React's defaults are perfect.
Because beginners see:
component functions running again
console logs repeating
unexpected useEffect calls
changes they didn't expect
This creates the illusion that something is wrong.
But in React:
Re-running is normal.
Re-rendering is expected.
Re-evaluating is routine.
React workloads are tiny and efficient.
If you use React Strict Mode, React will intentionally run components twice to detect side-effect problems.
This happens ONLY in development.
In production, everything runs once.
Strict Mode helps you:
catch missing cleanups
catch unsafe logic
catch side-effect bugs
useEffect runs AFTER the component renders.
If a dependency changes:
Component re-renders
useEffect runs again
Cleanup (if needed) runs before re-running
If you misunderstand rendering, useEffect feels unpredictable.
Once you understand rendering, useEffect becomes logical.
Updating state unnecessarily
Beginners often update state even if the new value is the same.
Storing values in state that don't need to be there
Derived values should not be in state.
Passing inline objects/functions as props
React sees them as "new" on every render.
Using context for too many values
Context re-renders every consumer when changed.
Not understanding parent-child relationships
If a parent re-renders, children follow.
Only when:
your UI feels slow
hundreds of components re-render unnecessarily
expensive logic runs repeatedly
lists are large
animation lags occur
React is already fast.
Premature optimization causes more issues than it solves.
React Rendering and re-rendering might feel complex at first, but the core ideas are simple:
Components render when state, props, or context change.
Rendering is cheap; DOM updates are optimized.
React re-renders entire components, not fragments.
Re-rendering is normal not a performance issue.
Virtual DOM ensures only necessary updates hit the screen.
Master rendering, and React becomes predictable, stable, and enjoyable.
AnNo. Only components affected by state/props/context re-render.
Not usually. React is optimized for frequent re-renders.
Yes any change to state inside a component re-renders it.
Yes, unless optimized with special patterns.
No. Rendering updates the Virtual DOM; the real DOM updates only if needed.
Because of Strict Mode only during development.
React allows optimizations, but avoid them unless necessary.
Course :