HomeToolsAbout a20k

useMemo

What is it

Hook that lets you memoize/cache results of calculation between renders

  • only runs when one of its dependencies defined are updated

Use useMemo to keep expensive, resource intensive functions from needlessly running

const cachedValue = useMemo(calculatedValue, dependencies);

vs useCallback

useCallback is similar to useMemo, difference is that useCallback returns a memoized function whereas useMemo returns a memoized value

© VincentVanKoh