MCPcopy
hub / github.com/pmndrs/react-spring / useConstant

Function useConstant

packages/shared/src/hooks/useConstant.ts:8–16  ·  view source on GitHub ↗
(init: Init<T>)

Source from the content-addressed store, hash-verified

6 * Creates a constant value over the lifecycle of a component.
7 */
8export 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}

Callers 1

useSpringValueFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…