本文介绍了升级到 React Native 0.62.0 获取警告标志 - 不再需要在 Animated 组件的 ref 上调用 `getNode()`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将我的 React Native 应用程序升级到 0.62.0,现在我的应用程序不断收到此警告标志

I just upgrade my react native app to 0.62.0, and now my app keeps getting this warning sign

ReactNativeFiberHostComponent: Calling `getNode()` on the ref of an Animated component 
is no longer necessary. You can now directly use the ref instead. 
This method will be removed in a future release.

我不知道为什么会出现这个问题?有人可以解释一下吗?

I'm not sure why this issue is showing up? Can someone please explain?

我也看到了堆栈

ref.getNode |
createAnimatedComponent.js:129:20

SafeView#_updateMeasurements | index.js:192:14

SafeView#componentDidUpdate | index.js:154:9

更新

我相信这可能来自 react-navigation 的 SafeAreaView

I believe this might be coming from SafeAreaView from react-navigation

推荐答案

我也是在ro RN 0.62.1升级后出现这个警告的,我根本没用getNode(),原来它来自我使用的依赖项,称为 react-native-snap-carousel,因为它们使用 FlatList 构建它,并且可能还使用 getNode().

I also came to this warning after upgraded ro RN 0.62.1, and I didn't use getNode() at all, turns out it came from a depedencies that I use, called react-native-snap-carousel because they build it with FlatList and possibly using the getNode() as well.

现在在他们的 GitHub 存储库中有一个关于此的未决问题,我们可以关注,这里是 问题

And now there's an open issue about this in their GitHub repo that we can follow, here's the link to the issue

这也来自包react-native-safe-area-view,可能你的应用正在使用这个包,现在他们发布了新版本来修复getNode() 弃用,查看此 PR

this also came from package react-native-safe-area-view, possibly your app is using this package and now they have released new version to fix getNode() deprecation, see this PR

所以不要自己直接修复文件,你只需要更新包,只需运行:npm i react-native-safe-area-view

so instead of fixing the file directly yourself, you just need to update the package, simply run: npm i react-native-safe-area-view

希望有帮助:)

这篇关于升级到 React Native 0.62.0 获取警告标志 - 不再需要在 Animated 组件的 ref 上调用 `getNode()`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 13:50