MCPcopy Index your code
hub / github.com/CSFrequency/react-firebase-hooks / useComparatorRef

Function useComparatorRef

util/refHooks.ts:7–22  ·  view source on GitHub ↗
(
  value: T | null | undefined,
  isEqual: (v1: T | null | undefined, v2: T | null | undefined) => boolean,
  onChange?: () => void
)

Source from the content-addressed store, hash-verified

5};
6
7export const useComparatorRef = <T>(
8 value: T | null | undefined,
9 isEqual: (v1: T | null | undefined, v2: T | null | undefined) => boolean,
10 onChange?: () => void
11): RefHook<T | null | undefined> => {
12 const ref = useRef(value);
13 useEffect(() => {
14 if (!isEqual(value, ref.current)) {
15 ref.current = value;
16 if (onChange) {
17 onChange();
18 }
19 }
20 });
21 return ref;
22};
23
24export interface HasIsEqual<T> {
25 isEqual: (value: T) => boolean;

Callers 4

useDownloadURL.tsFile · 0.90
useIsFirestoreRefEqualFunction · 0.90
useIsFirestoreQueryEqualFunction · 0.90
useIsEqualRefFunction · 0.85

Calls 1

isEqualFunction · 0.70

Tested by

no test coverage detected