skip to content

Performance and Memoization

This is where React-specific optimization lives: what actually causes a re-render, how to prove it with a profiler, and which memoization, splitting, or virtualization technique is worth its cost. Interviewers use it to separate people who memoize by reflex from people who measure first.

part ofReactoverview, primer and where to startread it →
on this pageshow

explore

questions

page 2 of 2

A React dashboard stores the cursor position in state on the page component so a tooltip can follow the mouse, and every mousemove re-renders a heavy chart and table. Without memoizing the chart or the table, how would you restructure the components so only the tooltip updates?

level: seniorimportance: should knowfreq 38%

basics

~20 s

Isolate the high-frequency state in its own leaf component that owns the mousemove listener and renders only the tooltip. If that component must visually wrap the dashboard, have it take the chart and table as children so those elements keep their identity across its updates.

open as a page

In React, an extra re-render is not automatically a performance bug. How do you judge whether a particular re-render is costing anything, and which ones are worth eliminating?

level: seniorimportance: should knowfreq 42%

basics

~20 s

A re-render costs what it does: the size of the subtree it triggers, heavy computation in the render bodies, DOM changes the diff commits, and how often it repeats. Cheap renders at click rate are free; wide subtrees at keystroke rate are not.

open as a page

After virtualizing a 10,000-row React table, users report that the browser's Ctrl+F no longer finds rows and screen-reader users hear the wrong number of items. Why does windowing cause this, and what would you do about it?

level: seniorimportance: should knowfreq 34%

basics

~20 s

Native find-in-page, assistive-technology counts, printing and select-all all read the DOM, and windowing puts only a slice of rows there. Native find cannot be restored; you replace it with in-app search that scrolls to a match, declare true counts with ARIA, and manage focus across unmounts.

open as a page

You are virtualizing a React chat log where each message's height depends on its content, so offsets cannot be computed from a single row height. How do virtualizers handle unknown row heights, and what goes wrong while the measurements settle?

level: seniorimportance: should knowfreq 40%

basics

~20 s

The virtualizer starts from an estimated height per row, renders the window, then measures each mounted row and caches its real height, rebuilding the offset table and total size. Until a row is measured its position is a guess, so correcting rows above the viewport shifts content unless the scroll is compensated.

open as a page

How would you roll the React Compiler out across a large existing React codebase, and what would you require before enabling it everywhere?

level: principalimportance: should knowfreq 22%

basics

~20 s

Adopt in stages: run the compiler's health check to size the work, make its ESLint rule blocking and burn down the violations, compile a low-risk slice first via annotation mode, verify with tests and before-and-after profiling, then widen. Opt-outs get owners and expiry.

open as a page

Your team's React app is slow and the proposed fix is to wrap most components in React.memo. As the lead, when do you require restructuring the component tree first, and when is a memo boundary the right tool?

level: principalimportance: should knowfreq 32%

basics

~20 s

Restructure first, because moving state down or relaying subtrees as content deletes the render work outright with no precondition to maintain. Reserve memo boundaries for the few places where the update genuinely must originate high and feed an expensive subtree unchanged props.

open as a page

In a project built with the React Compiler, what does adding the directive "use no memo" at the top of a component or hook function body do, and when should you reach for it?

level: juniorimportance: nice to knowfreq 25%

basics

~20 s

"use no memo" is a directive placed as the first statement of a function body that tells the React Compiler to skip that one component or hook, leaving it uncompiled. It is a temporary debugging escape hatch, not a permanent fix.

open as a page

React DevTools Profiler numbers are recorded from a development build running on a developer's machine. How do you decide which of those measurements are worth acting on?

level: principalimportance: nice to knowfreq 30%

basics

~20 s

Treat the Profiler as a comparative instrument, not an absolute one. Act on shape — commits per interaction, how much of the tree renders, how many components appear — and on before/after deltas from identical recordings, rather than on raw millisecond figures from a dev build on fast hardware.

open as a page

A team proposes a codebase-wide rule for a React 19 app: every component wrapped in React.memo and every callback wrapped in useCallback, enforced in code review. How would you evaluate that proposal?

level: principalimportance: nice to knowfreq 30%

basics

~20 s

Reject it as a blanket rule. Memoizing everything adds comparisons, retained caches and dependency arrays across the whole codebase, and most of those wrappers never skip anything. Target memoization at boundaries where profiling shows a real cost.

open as a page

You are designing a rollout where React's `<Profiler>` feeds render timings into your telemetry pipeline. What decisions would you settle before turning it on for real traffic, and how do you keep the instrumentation from distorting what it measures?

level: principalimportance: nice to knowfreq 20%

basics

~20 s

Settle what decision the data will drive, then place a handful of Profilers at meaningful boundaries, buffer and aggregate in the callback instead of sending per commit, sample traffic rather than instrumenting everyone, and agree in advance when the instrumentation gets removed.

open as a page

A React team proposes virtualizing every long list in the product. As the reviewer, how do you decide which lists genuinely warrant windowing, and what would you push back on?

level: principalimportance: nice to knowfreq 26%

basics

~20 s

Decide from measured production data: the p95 row count, the DOM and render cost of a single row, and whether scrolling actually drops frames. Windowing earns its permanent complexity and accessibility cost only for lists that are genuinely large and cannot be shortened.

open as a page

showing 31–41 of 41