Files
est-frame/node_modules/@restart/hooks/esm/useRefWithInitialValueFactory.d.ts
2025-10-22 05:38:27 +00:00

15 lines
543 B
TypeScript
Executable File

/// <reference types="react" />
/**
* Exactly the same as `useRef` except that the initial value is set via a
* factory function. Useful when the default is relatively costly to construct.
*
* ```ts
* const ref = useRefWithInitialValueFactory<ExpensiveValue>(() => constructExpensiveValue())
*
* ```
*
* @param initialValueFactory A factory function returning the ref's default value
* @category refs
*/
export default function useRefWithInitialValueFactory<T>(initialValueFactory: () => T): import("react").MutableRefObject<T>;