Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgraded to React Native 0.62.0 Getting Warning Sign - "Calling `getNode()` on the ref of Animated component is no longer necessary

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?

I also see Stack

ref.getNode |
createAnimatedComponent.js:129:20

SafeView#_updateMeasurements | index.js:192:14

SafeView#componentDidUpdate | index.js:154:9

Update

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

like image 928
hellomello Avatar asked Mar 29 '20 05:03

hellomello


2 Answers

To quick fix this go to node_modules/react-native-safe-area-view => index.js

at line 192 change

this.view.getNode().measureInWindow((winX, winY, winWidth, winHeight)

to

this.view.measureInWindow((winX, winY, winWidth, winHeight)

like image 89
Wenushka Mallikarachchi Avatar answered Oct 05 '22 03:10

Wenushka Mallikarachchi


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.

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

Update

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

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

Hope that's help :)

like image 32
Alvin Novian Avatar answered Oct 05 '22 02:10

Alvin Novian