Understanding React Rendering and Re-Rendering

Related Courses

Next Batch : Invalid Date

Next Batch : Invalid Date

Next Batch : Invalid Date

Next Batch : Invalid Date

Next Batch : Invalid Date

Next Batch : Invalid Date

Understanding React Rendering and Re-Rendering

Introduction: The Moment Every React Learner Gets Confused

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.

1. What Does "Rendering" Mean in React? (Simple Explanation)

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

Important:

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.

2. What Is Re-Rendering?

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.

3. Why Does React Re-Render? (The Exact Triggers)

React re-renders components when:

  1. A component's state changes
    If you update state in a component, React re-renders that component.

  2. A component receives new props
    If the parent sends new data, the child re-renders.

  3. A parent component re-renders
    When a parent re-renders, all children re-render by default.

  4. A context value used by the component changes
    Any component consuming context will re-render when the context updates.

  5. A hook dependency changes
    For example, effects re-run when dependencies change.

  6. Strict Mode (dev only) intentionally re-renders components twice
    This helps you catch bugs and side-effect issues.

These are the fundamental triggers.

4. Important: Rendering is NOT Always Bad

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.

5. Rendering vs Commit: The Two Phases You Must Know

React's UI update process has two distinct phases:

Phase 1: Render Phase

  • 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.

Phase 2: Commit Phase

  • React updates the real DOM

  • Applies changes to actual elements

  • Browser paints the final UI

This is the phase that the user sees.

Simplified Understanding

Render = Thinking
Commit = Doing

React "thinks" first, then "does."

6. The Virtual DOM Makes Rendering Efficient

React uses a lightweight in-memory representation of the UI called:
The Virtual DOM

When your component renders, React:

  1. Creates a new Virtual DOM snapshot

  2. Compares it with the old one (diffing)

  3. Finds exactly what has changed

  4. Updates only those parts in the real DOM

Without Virtual DOM, re-rendering would be extremely slow.

7. What Happens Internally When React Renders?

When a component renders, React:

  1. Calls the component function

  2. Evaluates all variables inside it

  3. Evaluates JSX

  4. Builds a virtual UI description

  5. Prepares a list of DOM mutations

  6. Applies changes in the commit phase

Rendering does not directly update the screen React uses this process to stay fast and predictable.

8. Why React Re-Renders Entire Component Trees

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.

9. The 3 Core Causes of Re-Rendering (Must Remember)

If you remember only one section, remember this:

React re-renders a component when:

1. Its STATE changes

State belongs to a component. If state updates → component re-renders.

2. Its PROPS change

If a parent sends new props → child re-renders.

3. Its CONTEXT changes

If a component consumes context → updates trigger re-render.

Every re-render in React comes from one of these three.

10. Real-Time Example: State Causing Re-Rendering

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.

11. Real-Time Example: Props Causing Re-Rendering

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.

12. Real-Time Example: Parent Re-Rendering = Child Re-Rendering

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.

13. The Biggest Myth About Re-Rendering

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.

14. Re-Rendering Does NOT Mean Re-Drawing the DOM

Rendering ≠ DOM update.

React compares the Virtual DOM first.
If nothing changed, it updates nothing on the screen.

This is React's power.

15. How Often Does React Re-Render? (More Than You Think!)

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.

16. Why Re-Renders Feel "Scary" To Beginners

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.

17. React Strict Mode: Why Things Re-Render Twice in Dev

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

18. Re-Rendering and useEffect (Important Relationship)

useEffect runs AFTER the component renders.

If a dependency changes:

  1. Component re-renders

  2. useEffect runs again

  3. Cleanup (if needed) runs before re-running

If you misunderstand rendering, useEffect feels unpredictable.
Once you understand rendering, useEffect becomes logical.

19. Common Mistakes That Cause Unwanted Re-Renders

  1. Updating state unnecessarily
    Beginners often update state even if the new value is the same.

  2. Storing values in state that don't need to be there
    Derived values should not be in state.

  3. Passing inline objects/functions as props
    React sees them as "new" on every render.

  4. Using context for too many values
    Context re-renders every consumer when changed.

  5. Not understanding parent-child relationships
    If a parent re-renders, children follow.

20. When Should You Optimize Re-Renders?

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.

Conclusion: React Rendering Is Simple Once You Understand the Core Idea

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.

Frequently Asked Questions (FAQ)

1. Does React re-render the entire app on every state change?

AnNo. Only components affected by state/props/context re-render.

2. Is re-rendering bad for performance?

Not usually. React is optimized for frequent re-renders.

3. Does every state change trigger a re-render?

Yes any change to state inside a component re-renders it.

4. Do child components re-render when parents do?

Yes, unless optimized with special patterns.

5. Does re-rendering mean the DOM updates?

No. Rendering updates the Virtual DOM; the real DOM updates only if needed.

6. Why does React re-render twice in development?

Because of Strict Mode only during development.

7. Can I stop a component from re-rendering?

React allows optimizations, but avoid them unless necessary.