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
- Cache a function
- Skip re-rendering a component
- Keep the UI responsive during an update
- Load a component on demand
All performance and transitions commands · React 19 cheatsheet