React原生动画在安卓系统中崩溃



对此问题感到非常沮丧。

我正在设计一款需要动画的游戏。与世博会的Web部件配合良好。组件如下:

return (  <TouchableWithoutFeedback onPress={selectTarget}>
<Animated.View
style={{
width: 50,
height: 50,
backgroundColor: 'yellow',
zIndex: 2,
position: 'absolute',
alignItems: 'center',
justifyContent: 'center',
**transform: [
{ translateX: moveAnimation.x },
{ translateY: moveAnimation.y },
],**
elevation: 2,
left: 0, 
top: 0,
}}>
<Image style={[imageStyle]} source={imagesAssets[color]} />
</Animated.View>
</TouchableWithoutFeedback> );

然而,它在安卓系统上崩溃了(iOS很好(,错误如下:更新由RCTView 管理的视图的"转换"时出错

如果我注释掉转换位,它运行良好。

由于性能问题,我在动画配置中添加了useDeviceDriver:true,所以我必须使用transform。

有人能帮我解决这个问题吗?

最终找到了问题的原因:

moveAnimation计算过程中出现错误,未定义的值将导致应用程序崩溃,而不是将其视为0。

最新更新