FrontendReactPerformanceuseMemouseCallbackHooks

React Performance: useMemo and useCallback Explained

Avoid unnecessary re-renders and expensive recalculations. Learn exactly when useMemo and useCallback are worth using.

Abdur Razzak

Abdur Razzak

Full-Stack Web Developer

July 15, 2025 7 min read

When React Re-renders

React re-renders a component whenever its state or props change. Every function, object, and array defined inline in the component body gets a new reference on each render, which can trigger unnecessary re-renders in child components.

useMemo: Cache Expensive Calculations

useMemo returns a memoized value. React only recomputes it when one of the dependencies changes. Use it for expensive filtering, sorting, or transformation of large data sets — not for simple calculations where the memoization overhead outweighs the benefit.

useCallback: Stable Function References

useCallback returns a memoized version of a callback. This is useful when passing callbacks to child components wrapped in React.memo, because the callback reference stays stable between renders as long as the dependencies do not change.

The Golden Rule

Do not optimise prematurely. First write clear, correct code. Then measure with React DevTools Profiler or Chrome performance tools. Only add useMemo and useCallback where profiling reveals an actual performance problem.

Share this article

All posts
#React#Performance#useMemo#useCallback#Hooks
Abdur Razzak — Full Stack Web Developer
⭐ Top Rated

Upwork Top Rated Developer

Work With a Developer Clients Trust