React Output Prediction Hard +35 XP
useMemo Return
When does useMemo recompute?
ReactRead-only
const value = useMemo(() => expensiveCalc(a, b), [a, b]);
What is the output?
Show answer and explanation
Answer: When a or b changes
useMemo caches the result and only recomputes when its dependencies (a or b) change.
Hint: The dependency array determines recomputation.
What this challenge tests
Output Prediction in React: hooks, performance.