gpt4 book ai didi

react-native - React Native - 按下按钮 "NativeAnimatedModule.startOperationBatch is not a function"

转载 作者:行者123 更新时间:2023-12-03 17:22:27 25 4
gpt4 key购买 nike

我正在尝试使用 Expo 创建我的第一个 React Native 应用程序,并且我正在尝试通过单击按钮来 console.log 一个随机文本。
当按下按钮时,我收到两个错误(这是通过 Android Studio):
1 - NativeAnimatedModule.startOperationBatch is not a function2 - There was a problem sending log messages to your development environment TypeError: stackString.split is not a function.有时我有时也会收到此错误

Animated node tag 3 does not exist
下面是我试图执行的简单代码
<View>
<TouchableOpacity
onPress={() => console.log('test')}
>
<Text>Log In</Text>
</TouchableOpacity>
</View>
我在网上看了一下,我真的没有看到关于这两个错误的任何信息。这是我设置代码的方式吗?我可能缺少包裹吗?
我暂时安装了这些 react-native 包
"react-native": "^0.64.0",
"react-native-gesture-handler": "^1.10.3",
"react-native-reanimated": "^2.0.0",
提前致谢

最佳答案

我可以按照 https://github.com/facebook/react-native/issues/29999 中提供的解决方案来解决这个问题。
这似乎是新版本 react native 中的一个 bug,要解决它,请转到 react-native/Libraries/Animated/NativeAnimatedHelper.js,然后将第 71 行更改为:

if (Platform.OS === 'android') {
NativeAnimatedModule.startOperationBatch();
}
if (Platform.OS === 'android' && NativeAnimatedModule.startOperationBatch) {
NativeAnimatedModule.startOperationBatch();
}
在第 78 行:
if (Platform.OS === 'android') {
NativeAnimatedModule.finishOperationBatch();
}
   if (Platform.OS === 'android' && NativeAnimatedModule.finishOperationBatch) {
NativeAnimatedModule.finishOperationBatch();
}
希望它会起作用。

关于react-native - React Native - 按下按钮 "NativeAnimatedModule.startOperationBatch is not a function",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66666328/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com