React-spring: Cannot access useSpring props in Typescript due to typing error.

Created on 20 Dec 2019  路  1Comment  路  Source: pmndrs/react-spring

馃悰 Bug Report

The following line is invalid in Typescript:

const { opacity, transform, ...rest } = useSpring(baseConfig);

With the messages:

Property 'opacity' does not exist on type 'AnimatedValue, never>>'.ts(2339)

To Reproduce

https://codesandbox.io/s/tender-sutherland-4b48l

(Forked from working js version: https://codesandbox.io/s/2v716k56pr?from-embed )

Expected behavior

Ability to reference animated props directly eg style={{opacity: animation.opacity}} instead of just style={animation}.
Currently impossible unless there is another way I'm unaware of.

Environment

  • react-spring v8.0.27
  • react v16.12.0
bug typescript v8

Most helpful comment

Please use v9 beta if you're a TypeScript user. The v8 types are unmaintained.

>All comments

Please use v9 beta if you're a TypeScript user. The v8 types are unmaintained.

Was this page helpful?
0 / 5 - 0 ratings