(init: Init<T>)
| 6 | * Creates a constant value over the lifecycle of a component. |
| 7 | */ |
| 8 | export function useConstant<T>(init: Init<T>) { |
| 9 | const ref = useRef<T | null>(null) |
| 10 | |
| 11 | if (ref.current === null) { |
| 12 | ref.current = init() |
| 13 | } |
| 14 | |
| 15 | return ref.current |
| 16 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…