Skip to content

Commit 9f0538f

Browse files
committed
Fix possible web crashed
1 parent df7cd90 commit 9f0538f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/react-native-gesture-handler/src/web/handlers/GestureHandler.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,13 @@ export default abstract class GestureHandler implements IGestureHandler {
701701
}
702702

703703
const rect = this.delegate.measureView();
704-
const { x, y } = this.tracker.getLastAbsoluteCoords();
704+
const lastCoords = this.tracker.getLastAbsoluteCoords();
705+
706+
if (!lastCoords) {
707+
return false;
708+
}
709+
710+
const { x, y } = lastCoords;
705711
const offsetX: number = x - rect.pageX;
706712
const offsetY: number = y - rect.pageY;
707713

packages/react-native-gesture-handler/src/web/tools/PointerEventManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export default class PointerEventManager extends EventManager<HTMLElement> {
9898
// pointer moves until it succeeds.
9999
// God, I do love web development.
100100
if (
101-
!target.hasPointerCapture(event.pointerId) &&
101+
!target?.hasPointerCapture(event.pointerId) &&
102102
!POINTER_CAPTURE_EXCLUDE_LIST.has(target.tagName)
103103
) {
104104
target.setPointerCapture(event.pointerId);

0 commit comments

Comments
 (0)