useMemo is a React Hook introduced in React 16.8 that caches the result of a calculation between re-renders to optimize performance by avoiding unnecessary expensive computations. It returns a memoized value that remains unchanged unless one of the specified dependencies in the array changes, compared using the Object.is algorithm.

Core Functionality and Syntax The hook takes a factory function and a dependency array as arguments: const memoizedValue = useMemo(() => computeExpensiveValue(a, b), [a, b]);.

  • Factory Function: A pure function that performs the calculation and returns the value to be cached.

  • Dependencies: A list of all reactive values (props, state, or variables) used inside the calculation.

  • Behavior: On the initial render, React executes the function. On subsequent renders, if dependencies remain the same, the cached value is returned; otherwise, the function re-runs.

Key Use Cases and Best Practices

  • Skipping Expensive Recalculations: Ideal for filtering large arrays or performing heavy computations where the result depends on props or state that might not change every render.

  • Memoizing Dependencies: Useful for preventing useEffect or other hooks from firing too often by ensuring a stable reference for dependencies.

  • Performance Optimization: Should only be relied upon when calculations are noticeably slow (e.g., taking 1ms or more), as the overhead of memoization can slow down trivial computations.

  • React Compiler: Modern React versions include a compiler that automatically memoizes values, potentially reducing the need for manual useMemo calls.

Limitations and Caveats

  • Top-Level Only: useMemo must be called at the top level of a component or custom hook; it cannot be used inside loops or conditions.

  • Strict Mode: In development, React may call the calculation function twice to verify purity, but this does not affect production logic.

  • Reference Equality: For arrays and objects in the dependency array, React checks for reference equality (===), meaning a new array instance will trigger a re-calculation even if the contents are identical.

  • Not for Side Effects: useMemo is for caching values, not for handling side effects; useEffect is the appropriate hook for that purpose.

🌐
React
react.dev › reference › react › useMemo
useMemo – React
On every subsequent render, React will compare the dependencies with the dependencies you passed during the last render. If none of the dependencies have changed (compared with Object.is), useMemo will return the value you already calculated before.
🌐
Medium
medium.com › @abhikshirsagar1999 › understanding-usememo-in-react-a-complete-guide-86c086bf3f27
Understanding useMemo in React: A Complete Guide | by Abhi Kshirsagar | Medium
November 25, 2024 - `useMemo` is a React hook introduced in React 16.8. It allows you to memoize a computed value so that it’s recalculated only when its dependencies change.
Discussions

Is useMemo still used?
Considering how many apps have been written in previous react versions, which have usememo and usecallback, you'll interact with these APIs whether you like or not, so you better learn More on reddit.com
🌐 r/reactjs
86
112
March 14, 2025
When to use or not use useMemo and useCallback?
I've found the easiest way to think about memoization is that every React component is just a function. If you define a variable within a function, every time that function gets called, the variable gets redefined. This is the same for React components - every time a component re-renders, the variables you define within that component get redefined. Often this isn't a problem, however if you're passing those variables down as props to child components, it means those child components get re-rendered too every time the variables change, because this is just how React works, and this is where memoization comes in. When you memoize a value (useMemo/useCallback) it means that value won't get redefined unless the values in its dependency array change. So because they don't get redefined, the components you pass those values to as props don't re-render because the props don't change. If you're only building a small app, sometimes you can get away with not memoizing anything, and in most cases I'd suggest not memoizing anything unless you run into performance problems. If you do though, there's a good chance the reason behind the performance problems is components rendering more times than they need to, which is where memoizing values can help. More on reddit.com
🌐 r/reactjs
38
71
February 27, 2023
How often to use useCallback/useMemo?
I believed that the “performance cost” of useMemo was a thing. But there are multiple articles out there (sorry, I’m in mobile right now - can’t link) that state this is not a thing, including profiling results and all. And like you stated, React Forget is is essentially going to do the same. The only reason to not put useMemo on virtually everything is legibility and complexity. And that’s a case by case consideration. I personally hate reading through a series of useMemos because it causes so much cognitive overhead for such a simple piece of code (a bunch of variables). More on reddit.com
🌐 r/reactjs
55
36
November 19, 2023
What is the purpose of useMemo-ing a whole component? A lack of trust of react change detection? Explicitly stating when the component should re-render?
The other answers saying "it's useless or a mistake" are unfortunately wrong. This is actually valuable for a little-known React performance optimization. If you return the exact same element reference as the last render, React will skip rendering that child. It's the same concept as wrapping a component in React.memo(), except it's controlled by the parent: https://blog.isquaredsoftware.com/2020/05/blogged-answers-a-mostly-complete-guide-to-react-rendering-behavior/#component-render-optimization-techniques As an example, this is how React-Redux's connect API implements avoiding renders of the child component if the props values haven't changed: https://github.com/reduxjs/react-redux/blob/v9.1.0/src/components/connect.tsx#L752-L779 More on reddit.com
🌐 r/reactjs
32
62
February 12, 2024
People also ask

What is React useMemo?
UseMemo is a built-in hook in React that allows you to memoize expensive functions so that you don't have to call them every time you render. Simply supply a function and an array of inputs to useMemo, and it will only recompute the memoized value if one of the inputs changes.
🌐
learnvern.com
learnvern.com › react js for web development › usememo in react
What is useMemo and Why Should You Use It?
How does useMemo work in React?
UseMemo is a built-in hook in React that allows you to memoize expensive functions so that you don't have to call them every time you render. Simply supply a function and an array of inputs to useMemo, and it will only recompute the memoized value if one of the inputs changes.
🌐
learnvern.com
learnvern.com › react js for web development › usememo in react
What is useMemo and Why Should You Use It?
What is difference between useEffect and useMemo?
The useMemo version renders 1 right away. The useEffect version renders null, then runs the effect, changes the state, then queues up a new render with 1 after the component renders.
🌐
learnvern.com
learnvern.com › react js for web development › usememo in react
What is useMemo and Why Should You Use It?
🌐
W3Schools
w3schools.com › react › react_usememo.asp
React useMemo Hook
The React useMemo Hook returns a memoized value.
🌐
Toontown Combos
zzzachzzz.github.io › blog › react-hooks-how-to-use-usememo
React Hooks: How to Use useMemo
March 5, 2021 - useMemo is a hook used to memoize values inside a React component. It's a performance optimization to avoid recalculating expensive values on every render.
🌐
Medium
austinrt.medium.com › demystifying-react-hooks-usememo-1219661d0af0
Demystifying React Hooks — useMemo | by austin | Medium
February 16, 2023 - If you’re here solely to understand ... React Docs, much like useCallback, useMemo is an opt-in performance enhancer Hook used to create referential equality for function results....
🌐
LearnVern
learnvern.com › react js for web development › usememo in react
What is useMemo and Why Should You Use It?
UseMemo is a built-in hook in React that allows you to memoize expensive functions so that you don't have to call them every time you render.
Published   November 11, 2021
Find elsewhere
🌐
Stackademic
blog.stackademic.com › understanding-and-utilising-reacts-usememo-hook-a-comprehensive-guide-b3e4d7e8b8ac
Understanding and Utilising React’s useMemo Hook: A Comprehensive Guide | by Prakash Chandra Muduli | Stackademic
February 29, 2024 - React’s useMemo hook is a powerful tool that allows developers to optimize the performance of their applications by memoizing the results of expensive computations.
🌐
Developerway
developerway.com › posts › how-to-use-memo-use-callback
How to useMemo and useCallback: you can remove most of them
The most important thing to remember here is that both useMemo and useCallback are useful only during the re-renders phase. During the initial render, they are not only useless but even harmful: they make React do some additional work. This means that your app will become slightly slower during the initial render.
🌐
WesionaryTEAM
articles.wesionary.team › demystifying-usememo-and-usecallback-hooks-in-react-5be7aee2f782
Demystifying useMemo and useCallback hooks in React | by Raju Shrestha | wesionaryTEAM
May 30, 2023 - The useMemo hook allows developers to memoize(cache) a function’s return value, preventing the function from being re-evaluated unless its dependencies change.
🌐
HackerNoon
hackernoon.com › when-and-how-to-use-usememo-in-react
When and How to Use useMemo in React | HackerNoon
May 30, 2023 - In this article, you will be able to learn what useMemo it and how to use it effectively
🌐
DigitalOcean
digitalocean.com › community › tutorials › react-usememo
Understanding the React useMemo Hook | DigitalOcean
October 9, 2020 - The dependencies act similar to arguments in a function. The dependency’s list are the elements useMemo watches: if there are no changes, the function result will stay the same. Otherwise, it will re-run the function. If they don’t change, it doesn’t matter if our entire component re-renders, the function won’t re-run but instead return the stored result.
🌐
Medium
medium.com › @sagarkarotia › usememo-in-reactjs-eb55015aca38
useMemo in Reactjs. useMemo is a React Hook that is used… | by Sagar | Medium
June 6, 2025 - useMemo is a React Hook that is used for memoization , It improves performance by avoiding expensive re-computations on every render…
🌐
DEV Community
dev.to › kansoldev › understanding-the-usememo-hook-47ae
Understanding the useMemo() hook - DEV Community
March 21, 2024 - The useMemo() hook is one of the built-in React hooks used for optimizing the performance of a React application, and it does this by caching the result of an expensive computation (Also known as Memoization).
🌐
LinkedIn
linkedin.com › pulse › reacts-usememo-hook-weapon-against-unnecessary-re-renders-b
React's useMemo Hook: A Weapon Against Unnecessary Re-renders
September 12, 2023 - The useMemo hook is a valuable tool for optimizing React applications. By memoizing values, objects. we can improve the performance and responsiveness of our components. These advanced use cases and code examples should help us to master useMemo ...
🌐
DZone
dzone.com › software design and architecture › integration › in-depth guide to using usememo() hook in react
In-Depth Guide to Using useMemo() Hook in React
February 27, 2023 - The useMemo() hook is a built-in React hook that allows you to optimize the performance of your React application by memoizing expensive computations. Memoization is the process of caching the results of a function call based on its input parameters.
🌐
GeeksforGeeks
geeksforgeeks.org › reactjs › react-js-usememo-hook
ReactJS useMemo Hook - GeeksforGeeks
February 8, 2025 - The useMemo Hook is a built-in React Hook that helps optimize performance by memoizing the result of a computation and reusing it unless its dependencies change.
🌐
Medium
medium.com › react-in-the-real-world › the-real-difference-between-usememo-and-memo-in-react-743c4cd3113a
The Real Difference Between useMemo and memo in React | by Dr. Derek Austin 🥳 | React in the Real World | Medium
April 9, 2023 - useMemo is a hook that allows you to cache a value that is computationally expensive to create or remains the same between renders. It takes a function and a dependency array as its arguments.