DEV Community

Mohan Mogi
Mohan Mogi

Posted on

useMemo Hook in React

useMemo:

  • useMemo is a React Hook used for performance optimization.

  • It returns a memoized value by storing the result of an expensive calculation in memory (cache) and reusing it during rerenders.

  • React recalculates the value only when one of its dependencies changes, helping avoid unnecessary calculations and improve application performance.

syntax:
const memoizedValue = useMemo(() => {
return calculation;
}, [dependencies]);

Top comments (0)