Skip to content

Commit b502fc0

Browse files
authored
Remove error with GestureHandlerRootView on web (#2558)
## Description Gestures on web don't work, unless they are wrapped inside `GestureHandlerRootView`. This PR removes the error, so that root view is no longer necessary. Fixes #2557 ## Test plan Tested on example app.
1 parent 33c3285 commit b502fc0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/handlers/createHandler.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ export default function createHandler<
402402
}
403403

404404
render() {
405-
if (__DEV__ && !this.context && !isJestEnv()) {
405+
if (__DEV__ && !this.context && !isJestEnv() && Platform.OS !== 'web') {
406406
throw new Error(
407407
name +
408408
' must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.'

src/handlers/gestures/GestureDetector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ interface GestureDetectorState {
612612
}
613613
export const GestureDetector = (props: GestureDetectorProps) => {
614614
const rootViewContext = useContext(GestureHandlerRootViewContext);
615-
if (__DEV__ && !rootViewContext && !isJestEnv()) {
615+
if (__DEV__ && !rootViewContext && !isJestEnv() && Platform.OS !== 'web') {
616616
throw new Error(
617617
'GestureDetector must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.'
618618
);

0 commit comments

Comments
 (0)