react-native-gesture-handler
react-native-gesture-handler copied to clipboard
[Web] Make `PointerTracker` elements nullable
Description
It was reported that in some cases Gesture Handler crashes on web on the following line. Seems like elements in PointerTracker may not exist, even though we believed that during our workflow they always do. Casts in PointerTracker were introduced because Map.get may return undefined if the element doesn't exist. Turns out that it actually may be the case, so we decided to remove those casts and handle these cases across our codebase.
While we don't know what exactly causes the fact that elements are not inside trackedPointers map, we have two possibilities:
- Pointer is removed form
PointerTrackerbefore handler entersBEGANstate - removing may happen for example when one lifts pointer from the view (callingonPointerUp, etc.). PointerTrackeris reset before handler entersBEGANstate - this one can happen whenpointercancelevent is received.
Test plan
Tested on expo-example on web