MCPcopy
hub / github.com/callstack/react-native-paper / useLazyRef

Function useLazyRef

src/utils/useLazyRef.tsx:3–11  ·  view source on GitHub ↗
(callback: () => T)

Source from the content-addressed store, hash-verified

1import * as React from 'react';
2
3export default function useLazyRef<T>(callback: () => T) {
4 const lazyRef = React.useRef<T | undefined>(undefined);
5
6 if (lazyRef.current === undefined) {
7 lazyRef.current = callback();
8 }
9
10 return lazyRef as React.MutableRefObject<T>;
11}

Callers 1

useAnimatedValueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…