Skip to content
Search

React:useMemo

lastmod 2026-03-11created 2026-01-093 edits

useMemo is a React Hook that lets you cache the result of a calculation between re-renders.

Example

const value = useMemo(() => {
    return calculate();
},[item])

useMemo, like useEffect, takes a callback function as the first argument and a dependency array (dependancyArray) as the second.

Only when a value in the dependency array updates does it call the callback again and update the value stored in memory.

If you pass an empty array, then, as with useEffect, it computes the value only on mount and after that keeps pulling out and using the memoized value.

See also

Favorite site

author Zer0 sitemap