1const memoizedResult = useMemo(() => {
2 return expensiveFunction(propA, propB);
3}, [propA, propB]);
1/*
2Pass a “create” function and an array of dependencies.
3useMemo will only recompute the memoized value when one
4of the dependencies has changed. This optimization helps
5to avoid expensive calculations on every render.
6*/
7const memoizedValue = useMemo(() => computeExpensiveValue(a, b), [a, b]);