React Re-render Rules and Profiling Bottlenecks0%

React Re-render Rules and Profiling Bottlenecks

Beginner12 min read•Updated: Jul 11, 2026
Study MaterialsCheatsheet

React Re-render Rules and Profiling Bottlenecks

1. Demystifying When React Re-renders

A pervasive myth among beginner and intermediate React developers is that components only re-render when their props change. This is completely false.

In standard React:

Whenever a component re-renders, React automatically re-renders ALL of its child components recursively, regardless of whether their props changed!
Output
Parent Component State Updates:
[Parent Re-renders]
│
├──► [Child 1 Re-renders!] (Props didn't change!)
│
└──► [Child 2 Re-renders!] (Props didn't change!)

2. The 4 Triggers of a Re-render

A component re-renders if and only if one of four events occurs:

  1. 1
    Local State Update: The component calls its own useState or useReducer updater function.
  2. 2
    Parent Component Re-render: The parent component re-renders (triggering an automatic downward cascade).
  3. 3
    Context Consumption: A React Context that the component subscribes to via useContext changes its value.
  4. 4
    Hook Update: A custom hook called inside the component triggers a state update.

3. Re-rendering vs DOM Updating

Engineers often panic when they see re-renders in DevTools, confusing a Virtual DOM re-render with a real DOM mutation.

  • Re-rendering: Executing the component function in memory to produce a new Virtual DOM tree. In modern JavaScript engines, this calculation is measured in microseconds and is extremely cheap.
  • Reconciliation & DOM Painting: Modifying physical DOM nodes on screen. React's diffing engine ensures that even if a component re-renders, the real browser DOM is only touched if the calculated output actually changed!

Re-renders only become a performance problem when:

  • Components perform expensive computations (e.g. large mathematical matrix operations, sorting 10,000 items).
  • Huge subtrees (hundreds of components) re-render on high-frequency events like typing or scrolling.

4. Profiling Bottlenecks with React DevTools

Never optimize blindly! Use the React DevTools Profiler to identify genuine bottlenecks:

  1. 1
    Open DevTools -> Profiler tab.
  2. 2
    Click Record (blue circle).
  3. 3
    Interact with the application (e.g. type in a search box).
  4. 4
    Click Stop.
  5. 5
    Examine the Ranked Chart:
  • Components are ordered by the amount of time they took to render.
  • Look for wide, yellow, or red bars (components taking >16ms, dropping 60fps frames).
  • Inspect "Why did this render?" to discover the root cause.

Interactive Quiz

Practice Quiz

Question 1
In standard React, what happens to child components when their parent component re-renders?
Question 2
What is the difference between a component "re-rendering" and React "updating the DOM"?
Question 3
How many milliseconds does a render have before it drops below 60 frames per second (causing visible UI lag)?
Question 4
Which tool should you use to measure exactly which components re-rendered and how long each render took?
Question 5
Which of the following does NOT cause a component to re-render?
Next Lesson

Memoizing Components with React memo

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

PrevNext