mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
13 lines
259 B
TypeScript
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;
|
||
|
}
|