EvanBacon / react-native-web-hooks

Hooks for React Native web and Expo
MIT License
197 stars 10 forks source link

getNode is being phased out #29

Open jennifer-dickinson opened 1 year ago

jennifer-dickinson commented 1 year ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch react-native-web-hooks@3.0.2 for the project I'm working on.

This resolved a warning about getNode being deprecated in the future.

Screenshot:

Screenshot 2023-03-29 at 10 07 57 AM

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-web-hooks/build/createPseudoHook.js b/node_modules/react-native-web-hooks/build/createPseudoHook.js
index 2c544fb..002cda5 100644
--- a/node_modules/react-native-web-hooks/build/createPseudoHook.js
+++ b/node_modules/react-native-web-hooks/build/createPseudoHook.js
@@ -11,7 +11,7 @@ export default function createPseudoHook({ events }) {
         const [isActive, setActive] = React.useState(false);
         React.useEffect(() => {
             const [eventIn, eventOut] = events;
-            const node = getNode(ref);
+            const node = ref.current;
             if (!node) {
                 return;
             }

This issue body was partially generated by patch-package.

jamielife commented 1 year ago

This also resolves, "Couldn't find node Error: Argument appears to not be a ReactComponent. Keys: current" I was getting after import.

km-tr commented 4 months ago

@EvanBacon Are there no more plans for updates? I would appreciate it if you could include changes like this for React 19.