question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

After upgrade to 2.4.1 types for style prop (Animated.View) are incompatible with Animated.Value

See original GitHub issue

Description

After upgrade from 2.2.4 to the latest version (2.4.1) I’m getting many TypeScript errors in all places where I use Animated.View with Animated.Value from Reanimated v1.

Expected behavior

Types shouldn’t throw errors to valid usage of style prop.

Actual behavior & steps to reproduce

 <Animated.View
            style={{
                opacity: animation.current,
            }}
        >
        
        </Animated.View>

That’s throw error but refactored to

 <Animated.View
            style={[{
                opacity: animation.current,
            }]}
        >
        
        </Animated.View>

works fine

Snack or minimal code example

const Component = () => {
 
 const animation = useRef(new ReAnimated.Value(Dimensions.get('window').height));}
 ....
 
 <Animated.View
            style={{
                left: 0,
                top: animation.current,  <----- this line throw TS error after upgrade
                right: 0,
                bottom: trueBottom * -1,
                backgroundColor: colors.GRAY_50,
                zIndex: 99,
            }}
        >
        
         ......
        </Animated.View>

TS Error:

TS2769: No overload matches this call.
Overload 1 of 2, ‘(props: AnimateProps<ViewProps> | Readonly<AnimateProps<ViewProps>>): View’, gave the following error.
Type ‘{ position: "absolute" | "relative"; display: "none" | "flex"; left: number; top: ReAnimated.Value<number>; right: number; bottom: number; backgroundColor: string; zIndex: number; }’ is not assignable to type ‘((false | ViewStyle | RegisteredStyle<ViewStyle> | RecursiveArray<Falsy | ViewStyle | RegisteredStyle<ViewStyle>> | AnimatedNode<…>) & (false | … 4 more … | RecursiveArray<…>)) | null | undefined’.
Type ‘{ position: "absolute" | "relative"; display: "none" | "flex"; left: number; top: ReAnimated.Value<number>; right: number; bottom: number; backgroundColor: string; zIndex: number; }’ is not assignable to type ‘undefined’.
Overload 2 of 2, ‘(props: AnimateProps<ViewProps>, context: any): View’, gave the following error.
Type ‘{ position: "absolute" | "relative"; display: "none" | "flex"; left: number; top: ReAnimated.Value<number>; right: number; bottom: number; backgroundColor: string; zIndex: number; }’ is not assignable to type ‘((false | ViewStyle | RegisteredStyle<ViewStyle> | RecursiveArray<Falsy | ViewStyle | RegisteredStyle<ViewStyle>> | AnimatedNode<…>) & (false | … 4 more … | RecursiveArray<…>)) | null | undefined’.
Type ‘{ position: "absolute" | "relative"; display: "none" | "flex"; left: number; top: ReAnimated.Value<number>; right: number; bottom: number; backgroundColor: string; zIndex: number; }’ is not assignable to type ‘undefined’.

Package versions

name version
react-native 0.66.4
react-native-reanimated 2.4.1
TypeScript 4.5.4
NodeJS
Xcode
Java
Gradle
expo

Affected platforms

  • Android
  • iOS
  • Web

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:8
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
piaskowykcommented, Apr 1, 2022
2reactions
magrinjcommented, Jun 20, 2022

Still present on 2.8.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Animated.Value - React Native
Standard value for driving animations. One Animated.Value can drive multiple properties in a synchronized fashion, but can only be driven by one ...
Read more >
Shared Values | React Native Reanimated - Software Mansion
Shared Values cannot be directly hooked as View's props. You should use useAnimatedStyle or useAnimatedProps where you can access Shared Values and return...
Read more >
react-native-reanimated - npm
React Native Reanimated provides a more comprehensive, low level abstraction for the Animated library API to be built on top of and hence ......
Read more >
The Elementor Pro Changelog- Version Updates
Fix: Inline HTML elements appear as plain text in Animated Headline widget ... V3 integration conflict with required fields validation in Forms widget ......
Read more >
2.4. Graphics — Hands-on Python Tutorial for Python 3
A GraphWin is a type of object from Zelle's graphics package that automatically ... After you have checked out the picture, click with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found