KatInterview

React Internals: Rendering, Effects, Errors, and Concurrency

System DesignModel answer
MediumModel answerSystem Designreactfrontendhooks

Last updated

Walk through how React reconciles trees, when effects run, how to contain component failures, and what concurrent mode primitives actually buy you.

React Under the Hood

A solid grasp of React goes beyond knowing the hook names. The questions below probe why the library behaves the way it does and how to design around its failure modes.

1. Tree Diffing and Keys

React compares the previous render tree against the new one before touching the real DOM. Explain how that comparison works, what role the key prop plays, and what goes wrong when keys are unstable — for example, when you use an array index on a list that can be reordered or filtered.

2. useEffect and Dependency Tracking

Describe the difference between passing a list of variables to useEffect and passing an empty array []. When does React decide to call the cleanup function returned by an effect? What misconceptions do developers commonly hold about these behaviors?

3. Containing Failures in a Large UI

You are building a dashboard where dozens of independent widgets share the same page. A bug in one widget must not blank the entire screen.

  • Explain how Error Boundaries intercept failures and where their limits are (for example, why they don't catch errors thrown in a button's click handler).
  • Show how you would handle an error that surfaces inside an async function triggered by user interaction — both when the error is recoverable and when it should hand off to the nearest boundary.

4. Keeping the UI Responsive in React 18

React 18 introduced useTransition and useDeferredValue. Explain what class of problem each one solves, how they differ from each other, and when you would reach for one over the other.

For each topic, go beyond definitions: name the concrete failure mode the concept exists to prevent and what you would actually do about it.

Hints

Hint 1

For the diffing question, think about what React assumes when it sees two elements of the same type at the same position — and what it can't know without a key.

Hint 2

For effects, trace what happens step by step when a dependency changes: which callback runs first, and which values does it close over?

Hint 3

For async error handling, Error Boundaries only catch errors that surface during React's render or commit phase — so ask yourself: how could you get an async error back into that phase intentionally?