Performance Expert — Series 2
Preview — 3 of 10 questions
The React Compiler automatically inserts memoization where it can prove doing so is safe. When it encounters code whose safety it can't fully prove statically (like calling an arbitrary function from a prop, whose purity it has no way to verify), what does it do?
function ProductRow({ product, formatters }) {
// formatters is an object of functions passed as a prop —
// the compiler cannot statically prove these functions are pure/stable
const label = formatters.currency(product.price);
return <span>{label}</span>;
}Unlike the interactive DevTools Profiler tab (used for manual, ad-hoc investigation during development), what does wrapping part of the tree in the <Profiler> component with an onRenderCallback actually enable?
function onRenderCallback(id, phase, actualDuration, baseDuration, startTime, commitTime) {
if (actualDuration > 16) {
logSlowRender({ id, phase, actualDuration });
}
}
function App() {
return (
<Profiler id="Dashboard" onRenderCallback={onRenderCallback}>
<Dashboard />
</Profiler>
);
}startTransition-marked updates are described as interruptible. What's the actual underlying mechanism that makes this interruption possible, given JavaScript itself is single-threaded?
// Conceptually, how React processes a large low-priority update:
// [chunk of work] → check: has 5ms passed / is there pending urgent work? →
// if yes: pause, let browser handle input/paint/etc → resume later
// if no: continue with next chunkSign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.