React Native - 执行 UI 块时抛出异常 - 无法识别的选择器?

时间:2021-02-14 22:56:27

标签: javascript react-native animation components expo

我在 expo 中使用 React Native 并尝试为规模变化制作动画。我已将 https://github.com/tongyy/react-native-draggable#readme 分离到其自己的文件夹中,并正在修改源代码 (Draggable.tsx)。

标记返回一个 Animated.View here-

return (
    <Animated.View pointerEvents="box-none" style={positionCss}>
      {debug && getDebugView()}
      <Animated.View
        pointerEvents="box-none"
        {...animatedViewProps}
        {...panResponder.panHandlers}
        style={pan.current.getLayout()}>
        <TouchableOpacity
          {...touchableOpacityProps}
          onLayout={handleOnLayout}
          style={dragItemCss}
          disabled={disabled}
          onPress={onShortPressRelease}
          onLongPress={onLongPress}
          onPressIn={onPressIn}
          onPressOut={handlePressOut}>
          {touchableContent}
        </TouchableOpacity>
      </Animated.View>
    </Animated.View>
  );  

在 dragItemCss 中返回:

 return {
          ...style,
          justifyContent: 'center',
          width: renderSize,
          height: renderSize,
          transform: [{scaleX: 2}, {scaleY: 2}], //HERE
          shadowColor: 'black',
          shadowOffset: { width: 0, height: 0.5 * 20 },
          shadowOpacity: 0.1,
          shadowRadius: 0.8 * 20,
        };
      }, [children, isCircle, renderColor, renderSize, x, y, z]);

我应该可以在这里设置样式。我需要随着时间的推移修改变换比例值,所以我首先尝试了上面的方法,并且按钮缩放没有错误。

然而,当我将 scale 插入转换样式时,出现错误

const scale = React.useRef(new Animated.Value(1));
<块引用>

执行 UI 块时抛出异常 - [NSDictionaryM floatValue] 无法识别的选择器

这里发生了什么?如何为该组件的比例变化设置动画?

0 个答案:

没有答案