I just found a PR when a dev used useMemo
instead of useCallback
to memoize a function. It triggered my curiosity.
Are these two functions inside a React component/hook identical?
let b = 1;
const memoizedFunction = useMemo(
() => (a) => (a + b),
[b]
);
const memoizedFunction2 = useCallback(
(a) => (a + b),
[b]
);
At first glance, that appears to achieve the same goal.