Animated getLayout() function is not working in react-native

448 Views Asked by At

I'm using getLayout() method from Animated.ValueXY(). When executing the code, the error "TypeError: position.getLayout is not a function" is thrown. Can anyone please help me solving this?

  const [position, setposition] = useState(new Animated.ValueXY());
  const [swipeCardPosition, setSCposition] = useState(new Animated.ValueXY({
    x: 0,
    y: -SCREEN_HEIGHT - Constants.statusBarHeight
  }));
  const [index, setIndex] = useState({
    currentIndex: 0
  });
  const panResponder = useRef(PanResponder.create({.....})).current;
  
   return (
          <Animated.View
            key={item.id}
            style={swipeCardPosition.getLayout()}
            {...panResponder.panHandlers}
          >)
  

Error:enter image description here

0

There are 0 best solutions below