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

[Web] Add findNodeHandle web version #6403

Merged
merged 5 commits into from
Aug 12, 2024
Merged

Conversation

m-bert
Copy link
Contributor

@m-bert m-bert commented Aug 11, 2024

Summary

In many places we use findNodeHandle function to get native view that is represented by React component. The problem is that usage of this function on web leads to warnings (which are shown via console.error), that this function in deprecated and should not be used.

I've already done 3 PRs that remove usage of findNodeHandle on web, but it keeps reappearing. That's why I've decided to create our version of this function. On native platforms it is just export from react-native. On web it returns component that is passed into the function.

Caution

Note that findNodeHandle(or to be exact, findDOMNode) will be removed in next major version of React (i.e. React 19)

Test plan

Verifed on our web-example that it uses web version of findNodeHandle.

Note

In our example app you can still see depracation warning. This is because of GestureDetector from react-native-gesture-handler and it has to be fixed in mentioned library.

@m-bert m-bert marked this pull request as ready for review August 11, 2024 14:03
Copy link
Collaborator

@tjzel tjzel left a comment

Choose a reason for hiding this comment

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

Solid work!

@m-bert m-bert added this pull request to the merge queue Aug 12, 2024
Merged via the queue into main with commit 4ff82bd Aug 12, 2024
6 checks passed
@m-bert m-bert deleted the @mbert/add-find-node-handle-wrapper branch August 12, 2024 08:48
@gaearon
Copy link
Contributor

gaearon commented Nov 18, 2024

findNodeHandle is just as bad on React Native. See #6719.

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.

4 participants