Skip to content

API Reference / @gtkx/animated / useSpringValue

Variable: useSpringValue

const useSpringValue: <T>(initial, props?) => SpringValue<T>

Defined in: node_modules/.pnpm/@react-spring+core@10.1.2_react@19.2.8/node_modules/@react-spring/core/dist/react-spring_core.modern.d.mts:1130

Creates a constant single SpringValue that can be interacted with imperatively. This is an advanced API and does not react to updates from the parent component e.g. passing a new initial value

jsx
export const MyComponent = () => {
  const opacity = useSpringValue(1)

  return <animated.div style={{ opacity }} />
}

Type Parameters

T

T

Parameters

initial

Exclude<T, object>

– The initial value of the SpringValue.

props?

SpringUpdate<T>

– Typically the same props as useSpring e.g. config, loop etc.

Returns

SpringValue<T>

Released under the MPL-2.0 License.