Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Trying to animate opacity, Reanimated2

$
0
0

I work on a slider. I passing a currentIndex property to my component and I want it to be used to animate.

See:

interface DotProps {  index: number;  currentIndex: Animated.Node<number>;}export const Dot = ({index, currentIndex}: DotProps): JSX.Element => {  const x = useSharedValue(currentIndex);  const opacityStyles = useAnimatedStyle(() => {    return {      opacity: interpolate(        currentIndex,        [index - 1, index, index + 1],        [0.5, 1, 0.5],        Extrapolate.CLAMP,      ),    }  });  {/* rest of code */}

On the parent view, I used the Dot component this way:

{slides.map((_, index) => (<Dot    key={index}    currentIndex={divide(x.value, width)}    {...{index}}  />))}

My problem is that I get the following error : Argument of type 'AnimatedNode<number>' is not assignable to parameter of type 'number'..

Can someone help me solve this please ?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>