Reanimated2 interpolateNode to animate opacity error "undefined is not an object (evaluating t.length)"

971 Views Asked by At

I'm using react-native (not expo), the react-native version is 0.64.2 The reanimated version is 2.2.3 Having some problems with reanimated2 interpolateNode. Here is the snack reproducing the problem https://snack.expo.dev/@vladid/juicy-raspberries

Here is the code:

function AnimatedSomething(){


  const inputRange = [0, 1];
  const outputRange = [1, 0.4];
  const sharedPosition = useSharedValue(1);
  const opacityStyle = useAnimatedStyle(() => {
    const opacity = interpolateNode(
        sharedPosition.value, 
        inputRange,
        outputRange
      );

      return {
        opacity
      }
  })

What am I missing? Thank you in advance.

1

There are 1 best solutions below

0
On BEST ANSWER

Maybe my previous answer from : https://stackoverflow.com/a/71873715/12637199 might help you.

If not, try removing the reanimated version and use native animation from react-native which is working perfectly fine.

And you are adding a useless value in your interpolate:

const sharePosition = new Animated.Value(1);

const animatedOpacity = sharePosition.interpolate({inputRange, outputRange});