react-native-reanimated: web: useAnimatedGestureHandler not working
Description
That is working on android, but on the web the gesture event is not called
Screenshots
Steps To Reproduce
const gestureHandler = useAnimatedGestureHandler(
{
onStart: (_, ctx: any) => {
//notCalled
},
onActive: (event, ctx) => {
//notCalled
},
onEnd: (_) => {
//notCalled
},
},
[],
);
Expected behavior
Actual behavior
Snack or minimal code example
Package versions
- React: 17.0.1
- React Native: 0.63.1
- React Native Reanimated: 2.0.0-alpha.8
- React Native Gesture Handler: 1.8.0
- NodeJS: 12
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 5
- Comments: 17 (11 by maintainers)
A single way to fix the first app example is just assign onDrag to PanGestureHandler’s onBegan prop.
This issue seems to have raised its head again, but managed to get it working using the above workaround, as below. I’ve been following along the Expo tutorial to create your first app and ran into this on the gestures step.
My package.json dependencies are:
@ElForastero thanks, I will reopen the issue and soon push the fix 🙌
@karol-bisztyga
Well, I finally made it working on both iOS and Web by manually defining handlers for PanGestureHandler.
useAnimatedGestureHandler
works well in native but seems like does absolutely nothing in web environment. Spend a while trying to understand the source of the problem, but with no success.“react”: “16.13.1”, “react-native”: “0.63.3”, “react-native-web”: “^0.14.7” “react-native-gesture-handler”: “^1.9.0”, “react-native-reanimated”: “^2.0.0-rc.0”,
UPD:
It looks like the issue is because of this.
WorkletEventHandler
is being passed into RNGH instead of regular listener. 🤔The issue in RNGH was fixed, but handler still doesn’t work on web.