-
-
Notifications
You must be signed in to change notification settings - Fork 977
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) setImmediate
is not defined
#2402
Labels
Comments
Hey! 👋 The issue doesn't seem to contain a minimal reproduction. Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem? |
Here's a patch for anyone who needs it: diff --git a/node_modules/react-native-gesture-handler/lib/module/handlers/gestures/GestureDetector.js b/node_modules/react-native-gesture-handler/lib/module/handlers/gestures/GestureDetector.js
index baf1ca3..0c9f50b 100644
--- a/node_modules/react-native-gesture-handler/lib/module/handlers/gestures/GestureDetector.js
+++ b/node_modules/react-native-gesture-handler/lib/module/handlers/gestures/GestureDetector.js
@@ -23,6 +23,8 @@ import { RNRenderer } from '../../RNRenderer';
import { isExperimentalWebImplementationEnabled } from '../../EnableExperimentalWebImplementation';
const ALLOWED_PROPS = [...baseGestureHandlerWithMonitorProps, ...tapGestureHandlerProps, ...panGestureHandlerProps, ...panGestureHandlerCustomNativeProps, ...longPressGestureHandlerProps, ...forceTouchGestureHandlerProps, ...flingGestureHandlerProps];
+const scheduleUpdate = Platform.OS == 'web' ? requestAnimationFrame : setImmediate;
+
function convertToHandlerTag(ref) {
if (typeof ref === 'number') {
return ref;
@@ -84,7 +86,7 @@ function attachHandlers({
// when it's ran
- setImmediate(() => {
+ scheduleUpdate(() => {
if (!mountedRef.current) {
return;
}
@@ -100,7 +102,7 @@ function attachHandlers({
// when it's ran
- setImmediate(() => {
+ scheduleUpdate(() => {
if (!mountedRef.current) {
return;
}
@@ -163,7 +165,7 @@ function updateHandlers(preparedGesture, gestureConfig, gesture, mountedRef) {
// in case of external relations)
- setImmediate(() => {
+ scheduleUpdate(() => {
if (!mountedRef.current) {
return;
} |
Thanks for providing the fix ❤️. |
j-piasecki
added a commit
that referenced
this issue
Feb 3, 2023
## Description Replace `setImmediate` with `requestAnimationFrame` on the web. Closes #2402. ## Test plan Tested on the Example app.
this works for me |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
GestureDetector
breaks on Next.js for usingsetimmediate
. This same thing was fixed on Reanimated by switching torequestAnimationFrame
Steps to reproduce
Use
GestureDetector
in Next.js causes this. It's an old bug from Reanimated.The fix is here: https://github.com/software-mansion/react-native-reanimated/pull/1521/files
Snack or a link to a repository
Let me know if this is needed.
Gesture Handler version
2.9.0
React Native version
RNW 0.18
Platforms
Web
JavaScript runtime
None
Workflow
None
Architecture
None
Build type
None
Device
None
Device model
No response
Acknowledgements
Yes
The text was updated successfully, but these errors were encountered: