When to Use useMemo

Use It For

  • Expensive calculations: sorting/filtering thousands of rows, heavy math.
  • Keeping the same object/array reference to pass to a React.memo child or into a dependency array.

Note: Do not wrap every value: memoization has its own cost. Measure first (React DevTools Profiler).