-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
fix: Added dependency array for react native web project (crashing react native reanimated 3.X) #11496
Conversation
Signed-off-by: Agustin Vazquez <agustin.vazquez@copilotiq.com>
Hey @agusvazquez! Thanks for opening your first pull request in this repo. If you haven't already, make sure to read our contribution guidelines. |
✅ Deploy Preview for react-navigation-example ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Signed-off-by: Agustin Vazquez <agustin.vazquez@copilotiq.com>
Signed-off-by: Agustin Vazquez <agustin.vazquez@copilotiq.com>
Hello! Can someone review this? Need this merged in so drawer works on react navigation web using RN Reanimated v3 and react native v 0.72.X. Thank you! |
just curious... i tested with a pactch-package with your changes but still not getting drawer to work properly in web. does it work only for react-natve v0.72.x? im currenly at v0.71.x |
Hello @radelcom . Thanks for taking a look. To be 100% honest, I'm not sure. I just added the dependency array that react-native-reanimated v3.X.X needs in order to not crash on web. I tested those changes locally on my project and they worked fine. Also just to make sure, I am using React Native web for this project. I am using the following versions. "react-native": "0.72.3", Sorry, this is my first time sending a PR to a big library like this, not sure how to do a proper test btw (my test consisted in manually modifying the node_modules folder with my changes 😆 ). I'm noob at this. Any suggestions are welcome. |
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## main #11496 +/- ##
==========================================
+ Coverage 75.49% 75.67% +0.17%
==========================================
Files 190 202 +12
Lines 5742 5854 +112
Branches 2261 2304 +43
==========================================
+ Hits 4335 4430 +95
- Misses 1360 1372 +12
- Partials 47 52 +5 ☔ View full report in Codecov by Sentry. |
It's possible to run |
@tjzel Hello! I have just double checked and there were some hooks I was misisng. I have just updated the code. Please check! Also I looked for Hope this works! :) Cheers |
Good that you noticed |
@@ -310,7 +310,7 @@ export function Drawer({ | |||
: minmax(translationX.value - touchDistance, 0, drawerWidth); | |||
|
|||
return translateX; | |||
}); | |||
}, [touchStartX, drawerWidth, gestureState, drawerPosition, translationX]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With react-native-reanimated/plugin
auto-generated dependencies would be:
[drawerType, gestureState, GestureState, minmax, drawerPosition, touchStartX, drawerWidth, layout, translationX]
. Unless there's good reason not to include some of them here I'd rather keep them all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why shouldn't we? Had it been transpiled it would've been captured into dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it is a constant and it will never change.
Also, I am receiving the typescript error displayed above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, in the future it could be mutable (although I strongly doubt it) and enums are transpiled into JS objects, but I guess it's fair enough to not include it here.
@@ -337,7 +337,7 @@ export function Drawer({ | |||
}, | |||
], | |||
}; | |||
}); | |||
}, [touchStartX, drawerWidth, gestureState, drawerPosition, translationX]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it's:
[layout, drawerWidth, drawerType, translateX, drawerPosition, isRTL]
.
@@ -357,7 +357,7 @@ export function Drawer({ | |||
}, | |||
], | |||
}; | |||
}); | |||
}, [touchStartX, drawerWidth, gestureState, drawerPosition, translationX]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here:
[drawerType, translateX, drawerWidth, drawerPosition]
@@ -367,7 +367,7 @@ export function Drawer({ | |||
[getDrawerTranslationX(false), getDrawerTranslationX(true)], | |||
[0, 1] | |||
); | |||
}); | |||
}, [translateX, drawerType]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here:
[drawerType, interpolate, translateX, getDrawerTranslationX]
@@ -30,7 +30,7 @@ export const Overlay = React.forwardRef(function Overlay( | |||
// We can send the overlay behind the screen to avoid it | |||
zIndex: progress.value > PROGRESS_EPSILON ? 0 : -1, | |||
}; | |||
}); | |||
}, [progress, PROGRESS_EPSILON]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
@@ -40,7 +40,7 @@ export const Overlay = React.forwardRef(function Overlay( | |||
accessibilityElementsHidden: !active, | |||
importantForAccessibility: active ? 'auto' : 'no-hide-descendants', | |||
} as const; | |||
}); | |||
}, [progress, PROGRESS_EPSILON]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
I would wait with merging until we understand what causes #11483 |
Have pushed a new commit, please recheck @tjzel . Thanks for the feedback! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR. Can you add the functions to the ESLint config with "react-hooks/exhaustive-deps"
's additionalHooks
config so that any missing dependencies are caught by ESLint?
We mostly rely on the ESLint plugin to automatically add dependencies so it's crucial to configure ESLint to catch this scenario to avoid future bugs.
Added it @satya164 . Let me know if this is ok. Thank you! |
Thanks! Just few more things:
|
Hello 👋, this pull request has been open for more than a month with no activity on it. If you think this is still necessary with the latest version, please comment and ping a maintainer to get this reviewed, otherwise it will be closed automatically in 7 days. |
Please provide enough information so that others can review your pull request.
Motivation
Explain the motivation for making this change. What existing problem does the pull request solve?
I need to use react native reanimated v3 and I am facing the following issue on react native web.
#11483
If this pull request addresses an existing issue, link to the issue. If an issue is not present, describe the issue here.
#11483
Test plan
Describe the steps to test this change so that a reviewer can verify it. Provide screenshots or videos if the change affects UI.
Make sure the drawer works on react native web using react native reanimated v3.4.0
The change must pass lint, typescript and tests.