Javascript React Native如何获取panresponder中的元素位置

Javascript React Native如何获取panresponder中的元素位置,javascript,react-native,gesture,panresponder,Javascript,React Native,Gesture,Panresponder,我试图返回.measure的值,但似乎里面的代码在不使用状态的情况下无法交互,因此它一直返回false。我试图避免使用状态,因为我需要在我的PanResponder 度量函数返回false const showRefPosition = assignedRef => { let maxHeight = false; assignedRef.measure((x, y, width, height, pageX, pageY) => { const ma

我试图返回
.measure
的值,但似乎里面的代码在不使用状态的情况下无法交互,因此它一直返回false。我试图避免使用状态,因为我需要在我的
PanResponder

度量函数返回false

 const showRefPosition = assignedRef => {
    let maxHeight = false;

    assignedRef.measure((x, y, width, height, pageX, pageY) => {
      const maxY = SCREEN_HEIGHT - height;

      maxHeight = pageY - maxY < 40;
    });
    console.log("new maxHeight", maxHeight);

    return maxHeight;
  };

  const panResponder = useRef(
    PanResponder.create({
      onMoveShouldSetPanResponder: (event, gestureState) => {

        console.log("showRefPosition", showRefPosition(this.AnimatedRef));
        if (event.nativeEvent.pageY < 100) {

          pan.flattenOffset();
          Animated.spring(pan, {
            toValue: { x: 0, y: -600 },
          }).start();

          return false;
        }
        return Math.abs(gestureState.dy) > Math.abs(gestureState.dx * 3);
      },