useMemoizedValue
Return the previous value when the value has not changed. Use deep comparison by default.
API
function useMemoizedValue<T>(
value: T,
compare?: (x: any, y: any) => boolean
): T;
Params:
value
: The value.compare
: Comparison function.
Example
import { useMemo, DependencyList } from "react";
import { useMemoizedValue } from "@lilib/hooks";
function useDeepCompareMemo<T>(factory: () => T, deps?: DependencyList): T {
return useMemo(factory, useMemoizedValue(deps));
}
export default useDeepCompareMemo;