useMemo is a React Hook used to cache the result of a costly calculation between re-renders.
Skipping expensive recalculations
Skipping re-rendering of components
Memoizing a dependency of another Hook
Memoizing a function
It should be pure, should take no arguments, and should return a value of any type.
React will call this function during the initial render.
React will return the same value on the next renders if the dependencies have not changed since the last render.
Otherwise, it will call the calculatevalue function, return its result, and store it so it can be reused later.
By default, React re-renders all of its children recursively when a component re-renders. useMemo can also help you optimise the performance of re-rendering child components.
The list of all reactive values that are referenced inside the calculateValue code.
Reactive values include props, state, and all the variables and functions declared directly inside your component body.
Dependencies should also be memoised if they might be created on every render : const dependencyVariable={x:3, y:5}
How would you use useMemo to avoid recalculating a filtered list each time the component re-renders?
What happens if you omit the dependency array when calling useMemo?
Can you write a short snippet where useMemo wraps a heavy computation and explain why it helps?
We added a useMemo around a derived state, but the UI still feels sluggish. What could be causing that?
Why might a useMemo that depends on an object prop not memoize as expected, and how would you fix it?
When a component receives frequent prop updates, how do you decide which values belong in the useMemo dependency array?
Design a reusable Table component that memoizes row rendering. What trade‑offs do you consider between useMemo and React.memo?
During a code review you see a useMemo with a large dependency list causing unnecessary recomputations. How would you refactor it?
At scale, how does excessive useMemo affect memory usage and what strategies would you use to monitor or limit its impact?
Our monorepo has many legacy components using useMemo inconsistently. How would you create a migration plan to standardize memoization practices across teams?
When building a cross‑team shared data‑visualization library, how do you decide which calculations should be memoized with useMemo versus using a selector library like reselect?
Discuss the impact of useMemo on server‑side rendering and hydration performance, and how you'd guide teams to handle it.