“More memoization = more performance.”
Every memo has a cost: the comparison, the retained references, and the dependency array you now have to keep correct. Applied blindly, it is a net loss.
- Verdict
- BUSTED
- Level
- ENGINEER
- Division
- LAB-04
- References
- 02
Investigation
useMemo and useCallback trade CPU and memory for the chance to skip work later. That trade pays off only when three things are true: the skipped work is expensive, the dependencies genuinely stay stable, and the consumer can actually bail out.
// The child is not memoised, so it re-renders anyway.// All this adds is a comparison and a retained closure.const onClick = useCallback(() => setOpen(true), []);return <Button onClick={onClick} />;Memoisation also keeps values alive. A useMemo holding a large derived array retains it for the lifetime of the component, which is the desired behaviour when it is expensive to recompute, and a leak when it is not.
The React Compiler changes the economics: it inserts memoisation automatically where it can prove the component is pure, which removes both the manual effort and the class of bugs caused by wrong dependency arrays.
References
- 01React docsuseMemo, when to use
- 02React docsReact Compiler