software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
9.09k stars 1.32k forks source link

Replace findNodeHandle with reading _componentViewTag #6720

Closed gaearon closed 1 hour ago

gaearon commented 4 days ago

Summary

Partially addresses https://github.com/software-mansion/react-native-reanimated/issues/6719.

This is better because it doesn't enter the traversal codepath inside React. The findNodeHandle calculation inside the Animated.View itself is not so bad because it's short circuited inside for native refs (at least with View). Whereas passing a class instance like here always triggers the slower path in React. Regardless, it's already computed so why compute again?

Test plan

I've added console logs in our app to verify whether animatedComponent._componentViewTag === findNodeHandle(animatedComponent) and it always turned out true in the cases I hit.

Not sure if there any cases where those could be different.

tjzel commented 3 days ago

I recall there was an issue that if a component doesn't have its own native representation (it wraps a View for example) then we need to re-obtain the tag in some cases (when the underlying View changes). Not sure if it applies here however.