MCPcopy
hub / github.com/final-form/react-final-form / useConstant

Function useConstant

src/useConstant.ts:15–21  ·  view source on GitHub ↗
(init: () => T)

Source from the content-addressed store, hash-verified

13 * @param init - A function to generate the value
14 */
15export default function useConstant<T>(init: () => T): T {
16 const ref = React.useRef<T | undefined>(undefined);
17 if (!ref.current) {
18 ref.current = init();
19 }
20 return ref.current;
21}

Callers 1

ReactFinalFormFunction · 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…