KatInterview

React Rendering Deep Dive and a Re-render Fix Walkthrough

BehavioralModel answer
MediumModel answerBehavioralreactrenderingperformance

Last updated

Explain how React decides to render, reconcile and commit updates, then present a measured example of finding and fixing a rendering performance or correctness bug in a real app.

You are in a frontend technical screen. The interviewer asks you to pick a React application you have worked on, use it to explain how React renders, and then describe a rendering problem you diagnosed and fixed in it.

Assume a client-rendered app on React 18 or later unless you say otherwise. State that assumption at the start, and mention server rendering and hydration only briefly if relevant.

Part 1: How React renders

Explain:

  • What causes a component to render, including triggers that surprise people.
  • What happens in the render phase and in the commit phase, and when effects run.
  • How React compares the previous and next element trees to decide which DOM changes to make, including the roles of element type and keys.
  • How React batches state updates.

Part 2: A rendering problem from your experience

Describe a concrete case where rendering caused a performance or correctness problem. Cover:

  • The symptom and how you measured it.
  • The root cause, explained using the mechanics from Part 1.
  • The fix, its trade-offs, and a before-and-after measurement.
  • What you learned or would watch for next time.

Aim for a spoken answer of roughly five to eight minutes. Be specific about your own role.

Hints

Hint 1

Separate three ideas clearly: a component function being called (render), React computing a diff, and the browser DOM actually being mutated (commit). A re-render does not imply a DOM update.

Hint 2

For Part 2, pick one story with a measurable symptom (for example slow typing in an input, a janky list, or a wasted-render count in the Profiler) and structure it as situation, diagnosis, fix, result.

Hint 3

Justify each fix with a measurement and name its cost. Memoization has overhead and can be defeated by unstable props, so explain why your fix addressed the actual cause rather than applying it everywhere.