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 pageshowhide
explore
- Memoization Tradeoffs5 questions
- Referential Equality Traps4 questions
- Unnecessary Re-Render Causes4 questions
- React DevTools Profiler6 questions
- Profiler API4 questions
- Code Splitting with lazy and Suspense4 questions
- List Virtualization5 questions
- React Compiler5 questions
- Composition over Memoization4 questions
questions
page 2 of 2A 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?
basics
~20 sIsolate 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.
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?
basics
~20 sA 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.
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?
basics
~20 sNative 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.
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?
basics
~20 sThe 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.
How would you roll the React Compiler out across a large existing React codebase, and what would you require before enabling it everywhere?
basics
~20 sAdopt 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.
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?
basics
~20 sRestructure 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.
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?
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.
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?
basics
~20 sTreat 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.
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?
basics
~20 sReject 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.
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?
basics
~20 sSettle 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.
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?
basics
~20 sDecide 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.
showing 31–41 of 41