React 19 · Performance and transitions

Cache a calculation

Recompute only when the dependencies change.

const total = useMemo(() => items.reduce((s, i) => s + i.price, 0), [items]);

Official React 19 documentation

More performance and transitions commands

All performance and transitions commands · React 19 cheatsheet

Was this page helpful?