blakeblackshear.frigate/web/src/hooks/use-deep-memo.ts
2024-04-22 08:20:23 -06:00

13 lines
259 B
TypeScript

import { useRef } from "react";
import { isEqual } from "lodash";
export default function useDeepMemo<T>(value: T) {
const ref = useRef<T | undefined>(undefined);
if (!isEqual(ref.current, value)) {
ref.current = value;
}
return ref.current;
}