FS logo

Farhaan Shaikh

FS Blogs

HomeBlogsSubscribe

FS Blogs

Notes on building, shipping, and learning in public.

Essays, experiments, and honest lessons from the work behind this blog.

New posts, no noise.

One short email when something new is published.

No spam. Only new posts.

←Back to blogs

React re rendered my component

What triggers React to re render your component, and why re-rendering is not the same as updating the DOM.

🧩 Introduction

Blog image

Something weird happened again.

My React component re-rendered.

But…

  • I didn’t use setState
  • I didn’t update anything
  • No obvious changes

Still…

👉 React rendered again.

At this point, most developers think:

But that’s not true.

👉 React is doing exactly what it’s designed to do.

🧩 The Question

Blog image

So I asked myself:

👉 Why did React render again?

I didn’t change state.

I didn’t change props.

So what triggered it?

This is where most developers hit a wall.

Because they think:

👉 “Re-render only happens when state changes.”

That’s incomplete.

Let’s fix that mental model.

🧠 The Core Idea You Must Understand

👉 React does NOT track “what changed visually”

👉 React tracks signals

When a signal changes…

👉 React runs your component again.

🧩 Reason #1: State Changes

Blog image

This is the most obvious one.

typescript

const [count, setCount] = useState(0)

setCount(count + 1);

What happens:

  1. State updates
  2. React assumes UI might change
  3. Component runs again

Important insight:

React doesn’t check what changed in UI first.

👉 It re-runs the component first, then decides.

Why?

Because your UI is defined by your function:

javascript

return <h1>{count}</h1>

To know the new UI…

👉 React must run the function again.

🧩 Reason #2: Props Changes

Blog image

javascript

<Profile name="Farhaan" />

Later:

javascript

<Profile name="Ahmed" />

What happens:

  • Props changed
  • React re-runs the component

Why?

Because props are inputs to your component

If inputs change…

👉 Output (UI) might change.

Mental Model:

javascript

Component = Function(props) → UI

Change props → run function again.

🧩 Reason #3: Parent Re-render

Blog image

This is where most developers get surprised.

typescript

function Parent() {
  const [count, setCount] = useState(0)

  return (
    <>
      <button onClick={() => setCount(count + 1)}>Click</button>
      <Child />
    </>
  )
}

What happens:

  • Parent state changes
  • Parent re-renders
  • Child ALSO re-renders

Even if Child has no state?

👉 YES.

Why?

Because React re-runs the parent function.

And inside it:

javascript

<Child />

gets executed again.

🔥 Key Insight:

React does NOT track component boundaries like you think.

It follows the render tree.

Think of it like:

👉 If a parent runs, its children run too.

🧩 Reason #4: Context Updates

Blog image

typescript

const theme = useContext(ThemeContext)

If the context value changes:

javascript

"light" → "dark"

What happens:

👉 Every component using that context re-renders.

Why?

Because context is like global state for a tree

If it changes…

👉 React must update all consumers.

🧠 Now Let’s Connect Everything

From the slides:

  • State changes
  • Props changes
  • Parent renders
  • Context updates

These are the 4 main signals:

👉 “Run this component again”

🧩 The Big Confusion

Blog image

Now the big question:

👉 Does React just keep rendering everything all the time?

Short answer:

❌ No

✅ But it may look like it

Because you’re misunderstanding one thing:

👉 Re-render ≠ UI update

🧩 The Most Important Concept

Blog image

Re-render ≠ DOM Update

Re-render means:

👉 React ran your component function again

It does NOT mean:

👉 The browser updated the UI

Example:

javascript

function App() {
  console.log("Rendering...")

  return <h1>Hello</h1>
}

Even if this runs 100 times…

👉 The DOM might not change at all.

Why?

Because React compares:

  • Previous UI
  • New UI

If nothing changed…

👉 No DOM update.

🧠 This is HUGE

Most developers think:

👉 “Re-render = performance problem”

But that’s wrong.

Real cost:

❌ DOM updates are expensive

✅ Function execution is cheap

React optimizes this by:

👉 Running functions freely

👉 Updating DOM only when needed

🧩 So What Should You Do?

Blog image

Next time your component re-renders:

👉 Don’t panic.

Ask:

  • Did state change?
  • Did props change?
  • Did parent render?
  • Did context update?

If yes…

👉 React is working correctly.

Then the deeper question:

👉 Did the DOM actually change?

If not…

👉 There is NO performance issue.

🧠 Advanced Insight (This Separates Beginners from Pros)

React has two phases:

  1. Render phase (run components)
  2. Commit phase (update DOM)

Most developers confuse these two.

Reality:

👉 React may render 10 times

👉 But commit only once

That’s how React stays fast.

🧩 Conclusion

Blog image

Now you understand:

👉 Why components re-render

👉 What actually triggers them

Final Triggers Recap:

  • State changes
  • Props changes
  • Parent renders
  • Context updates

These are signals.

Not bugs.

🎯 Final Takeaways

  • Re-render = function execution
  • DOM update = actual UI change
  • They are NOT the same

One-line clarity:

👉 React re-renders to check if UI should change.

Not because it already changed.

🔥 Mindset Shift

❌ “Why is React re-rendering so much?”

✅ “React is verifying if UI needs updating”

🚀 What You Just Learned

You now understand:

  • The true meaning of re-render
  • What triggers it
  • Why it’s not a problem

🔜 Next Post Teaser

What actually happens after a re-render?

👉 Understanding the Virtual DOM

Post details

Published

Apr 6, 2026

Updated

Mar 31, 2026

Read time

6 min read

Tags

ReactTutorialGuideBest PracticesTechnical

Related posts

Why React Hooks Break?
ReactApr 17, 2026
Why React Hooks Break?Technical

Why React Hooks Break?

A deep dive into how React tracks hooks internally using an indexed system—and why breaking hook order causes bugs, crashes, and chaos.

Open article→
SetState feels broken
ReactApr 15, 2026
SetState feels brokenTechnical

SetState feels broken

React handles state updates internally—why setState is asynchronous, how batching works, and why your state sometimes feels “wrong”.

Open article→
Using index as keys
ReactApr 13, 2026
Using index as keysTechnical

Using index as keys

Why using index as key causes subtle bugs, and how to fix it using stable identities.

Open article→