UseMemo Interview Questions
3 curated usememo interview questions with detailed answers and examples.
← Browse all interview questionsFilter a list in real time by combining a controlled input with array filter(). Add debouncing for API search and useMemo for expensive client-side filtering.
useMemo caches the return value of a factory function and recomputes only when listed dependencies change. It prevents unrelated state changes from re-triggering expensive computations. It does not make a slow computation fast — when the dependency that drives the expense changes, the work runs regardless.
useMemo caches a computed value; useCallback caches a function reference. useCallback(fn, deps) is equivalent to useMemo(() => fn, deps). useCallback without React.memo on the child adds overhead with no benefit. Both require an accurate dependency array to avoid stale closures.