我正在使用 React Native(版本 0.59.10)构建一个项目。每当我运行测试(使用 Jest)时,我都会收到以下警告:
console.warn node_modules/react-native/Libraries/Animated/src/NativeAnimatedHelper.js:248
Animated: `useNativeDriver` is not supported because the native animated module is missing. Falling back to JS-based animation. To resolve this, add `RCTAnimation` module to this app, or remove `useNativeDriver`. More info: https://github.com/facebook/react-native/issues/11094#issuecomment-263240420
这似乎是由于“react-native-elements”又使用了Animated
in TouchableOpacity
which 。Button
用 Xcode 查看我的项目,我可以看到该RCNativeAnimation
项目在那里:
我检查了引用的链接:https ://github.com/facebook/react-native/issues/11094#issuecomment-263240420但它已经很老了,并且指的是 React Native 和 Xcode 的非常旧的版本。
我猜这个警告只是与RCNativeAnimation
无法从测试中访问的本机模块有关,但我不知道如何useNativeDriver
在测试上下文中“删除”。显然,在真正的应用程序中,我想确保我使用的是本机动画库,但在单元测试中我不在乎。
消除此警告的推荐方法是什么?