Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace findNodeHandle with reading _componentViewTag #6720

Merged
merged 2 commits into from
Nov 22, 2024

Conversation

gaearon
Copy link
Contributor

@gaearon gaearon commented Nov 18, 2024

Summary

Partially addresses #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
Copy link
Collaborator

tjzel commented Nov 18, 2024

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.

@piaskowyk piaskowyk self-requested a review November 20, 2024 16:05
Copy link
Member

@piaskowyk piaskowyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really appreciate that you reported the issue and submitted a PR! Thanks for your time 🙏. I wanted to address other areas where we use the findNode handler, so I've created another PR that builds upon yours - #6736

@piaskowyk piaskowyk added this pull request to the merge queue Nov 22, 2024
Merged via the queue into software-mansion:main with commit e6ef338 Nov 22, 2024
9 checks passed
@gaearon gaearon deleted the rm-findnodehandle branch November 22, 2024 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants