MCPcopy Create free account
hub / github.com/bvaughn/react-window / useMemoizedObject

Function useMemoizedObject

lib/hooks/useMemoizedObject.ts:4–16  ·  view source on GitHub ↗
(
  unstableObject: Type
)

Source from the content-addressed store, hash-verified

2import { shallowCompare } from "../utils/shallowCompare";
3
4export function useMemoizedObject<Type extends object>(
5 unstableObject: Type
6): Type {
7 const [memoizedObject, setMemoizedObject] = useState(unstableObject);
8
9 if (!shallowCompare(memoizedObject, unstableObject)) {
10 setMemoizedObject(unstableObject);
11
12 return unstableObject;
13 }
14
15 return memoizedObject;
16}

Callers 3

GridComponentFunction · 0.90
ListComponentFunction · 0.90

Calls 1

shallowCompareFunction · 0.90

Tested by

no test coverage detected