The React useMemo
Hook returns a memoized value.
Think of memoization as caching a value so that it does not need to be recalculated.
The useMemo
Hook only runs when one of its dependencies update.
This can improve performance.
The useMemo
and useCallback
Hooks are similar. The main difference is that useMemo
returns a memoized value and useCallback
returns a memoized function. You can learn more about useCallback
in the useCallback article.