(callback: () => T)
| 1 | import * as React from 'react'; |
| 2 | |
| 3 | export 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 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…