-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[docs] GestureHandlerRootView
#3970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a14db83
9e1f534
54889bb
3e82cf8
e005621
90b1aa4
a5b73b3
6c4aa0f
b2f97c5
8cb20ab
8f442f1
12abfeb
1094f92
d91e097
c503ea1
31a8db3
b3efbbe
d201b3e
62d0fe8
64aa192
4667c7d
5f40baf
800b37d
004f919
e8ddacc
128b226
cc1e783
d48e4ea
9f1ec51
9b4aff8
0ce4f89
1b48239
e9e88a5
5fcdc6c
6d909f3
4a901f8
17fc108
6563cdc
f3500a4
9840339
3d706ec
2a877d9
f927bf5
18e4350
8232dc8
6386f61
8ea2e67
aec1a4a
264a843
4fd4d8c
a09df73
6f8f71f
47b6daf
f94da57
c9c429e
ca8179c
941be7d
f315f93
8397376
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,48 @@ | ||||||
| --- | ||||||
| id: root-view | ||||||
| title: GestureHandlerRootView | ||||||
| sidebar_label: GestureHandlerRootView | ||||||
| sidebar_position: 3 | ||||||
| --- | ||||||
|
|
||||||
| `GestureHandlerRootView` is a key component that enables Gesture Handler to intercept touch events, allowing for the implementation of gestures in your app. It should wrap your app's main component, and any component that relies on Gesture Handler's gestures has to be a descendant of this view. For more detailed information, you can check out the [under-the-hood section](/docs/under-the-hood/how-does-it-work#android). | ||||||
|
|
||||||
| ```tsx | ||||||
| import { GestureHandlerRootView } from 'react-native-gesture-handler'; | ||||||
|
|
||||||
| export default function App() { | ||||||
| return ( | ||||||
| <GestureHandlerRootView> | ||||||
| <ActualApp /> | ||||||
| </GestureHandlerRootView> | ||||||
| ); | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| Keep `GestureHandlerRootView` as close to the actual root of the app as possible. It's the entry point for all gestures and all [gesture relations](/docs/fundamentals/gesture-composition). The gestures won't be recognized outside of the root view, and relations only work between gestures mounted under the same root view. | ||||||
|
|
||||||
| :::note | ||||||
| When integrating with navigation libraries, wrapping the navigator component with `GestureHandlerRootView` is generally sufficient. However, if you encounter issues with gestures not functioning properly, you might need to wrap each individual screen component with `GestureHandlerRootView` as well. | ||||||
| ::: | ||||||
|
|
||||||
| :::tip | ||||||
| If you're using Gesture Handler in your component library, you may want to wrap your library's code in the `GestureHandlerRootView` component. This will avoid extra configuration for the user. | ||||||
| ::: | ||||||
|
|
||||||
| ## Styling | ||||||
|
|
||||||
| `GestureHandlerRootView` can be thought of as a regular `View` component, therefore it accepts all the same props, including [`style`](https://reactnative.dev/docs/0.81/view-style-props). | ||||||
|
||||||
| `GestureHandlerRootView` can be thought of as a regular `View` component, therefore it accepts all the same props, including [`style`](https://reactnative.dev/docs/0.81/view-style-props). | |
| `GestureHandlerRootView` can be thought of as a regular `View` component, therefore it accepts all the same props, including [`style`](https://reactnative.dev/docs/view-style-props). |
Copilot
AI
Feb 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The “Nesting root views” section says nested root views are ignored, but later the page recommends adding a nested GestureHandlerRootView unstable_forceActive. On Android, nested root views are disabled by default but can be enabled when unstable_forceActive is set, so this section should clarify that nested root views are ignored unless unstable_forceActive forces the nested one to become active.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The navigation note is a bit ambiguous: it suggests wrapping the navigator is usually enough and wrapping individual screens is only needed when issues occur. However, the installation docs still state that with native navigation libraries (e.g. wix/react-native-navigation) each screen must be wrapped because each screen maps to a separate root view. Consider updating this note to explicitly call out that distinction (JS-based nav vs native nav) or linking directly to the relevant installation section to avoid misconfiguration.