Skip to content

Commit 6e8646a

Browse files
authored
[General] Throw when no gesture is passed to the GestureDetector (#3884)
## Description Adds an explicit error message when `GestureDetector` is rendered without any gesture. The current behavior is a random error when trying to call a method on `undefined`. ## Test plan Verify that the error is thrown when no gesture is passed.
1 parent 1427aae commit 6e8646a

File tree

1 file changed

+4
-0
lines changed
  • packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector

1 file changed

+4
-0
lines changed

packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ export const GestureDetector = (props: GestureDetectorProps) => {
9595
);
9696
}
9797

98+
if (!props.gesture) {
99+
throw new Error('GestureDetector must have a gesture prop provided.');
100+
}
101+
98102
// Gesture config should be wrapped with useMemo to prevent unnecessary re-renders
99103
const gestureConfig = props.gesture;
100104
propagateDetectorConfig(props, gestureConfig);

0 commit comments

Comments
 (0)