Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-native Animated api : undefined is not a constructor (evaluating 'new _reactNative.Animated.value(0)')

I was following the code from react native documentation for using Animated API here

I got an error while using this line

const scrollY = useRef( new Animated.value(0)).current;

ERROR : TypeError: undefined is not a constructor (evaluating 'new _reactNative.Animated.value(0)')

I have imported Animated from

import { Animated } from "react-native";

I don't know what I have done wrong, I am using the same code from the documentation

like image 778
abhi Avatar asked Jul 11 '26 13:07

abhi


1 Answers

It's:

const scrollY = useRef( new Animated.Value(0)).current;

Not

const scrollY = useRef( new Animated.value(0)).current;

From v to uppercase V

like image 93
crispengari Avatar answered Jul 14 '26 00:07

crispengari



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!