NativeViewGestureHandler must be used as a descendant of GestureHandlerRootView
Error: NativeViewGestureHandler must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized.Short answer
react-native-gesture-handler only recognises gestures inside GestureHandlerRootView. The error means a gesture component renders outside it. Wrap the whole app (or the navigator) in one root view, keep flex 1 in any custom style, and wrap screens separately if a navigator still fails.
Fix it fast
1Find out which cause you have
Find where the app root is rendered (App.tsx, or app/_layout.tsx with Expo Router) and check whether a GestureHandlerRootView surrounds everything.
grep -rn "GestureHandlerRootView" --include=*.tsx --include=*.js . --exclude-dir=node_modules2Match what you see, then jump to its fix
What does the error look like?
Error: NativeViewGestureHandler must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized.
Cause 1 of 3
No GestureHandlerRootView at the app root
1Check
Gestures are recognised only inside this view, so a gesture component with no root view above it raises the error.
grep -n "react-native-gesture-handler" package.json2Fix
Wrap the root of the app. With Expo Router, wrap the Stack in the root layout.
import { GestureHandlerRootView } from 'react-native-gesture-handler';
export default function App() {
return (
<GestureHandlerRootView>
<ActualApp />
</GestureHandlerRootView>
);
}3Verify
Reload the app. The red screen should be gone and swipes or drags should work.
npx expo start --clearConfirmed by docs.swmansion.com
Cause 2 of 3
The root view has a custom style without flex: 1
1Check
A style prop replaces the default. Without flex 1 the view has no height.
grep -rn -B1 -A1 "<GestureHandlerRootView" --include=*.tsx --include=*.js . --exclude-dir=node_modules2Fix
Add flex: 1 to the custom style.
<GestureHandlerRootView style={{ flex: 1, backgroundColor: '#fff' }}>
<ActualApp />
</GestureHandlerRootView>3Verify
The app renders again.
npx expo start --clearConfirmed by docs.swmansion.com
Cause 3 of 3
The root view is wrapped around the app but not around the failing screen
1Check
With a navigation library, wrapping the navigator is usually enough. Nested root views are ignored in favour of the top one, so a second wrapper elsewhere will not help.
grep -rn "GestureHandlerRootView" --include=*.tsx --include=*.js app src 2>/dev/null2Fix
Wrap the navigator once. If gestures still fail under it, wrap each screen component too.
function Screen() {
return (
<GestureHandlerRootView>
<ScreenContent />
</GestureHandlerRootView>
);
}3Verify
Open the failing screen directly.
npx expo start --clearConfirmed by docs.swmansion.com
How do I stop it coming back?
- Wrap the app once, at the true root, when you add the library.
- Install with npx expo install so the version matches your SDK.
- Keep flex: 1 in every custom root view style.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- TaskvareA task and project-management suite: React on the web, Flutter on mobile, TypeScript underneath.
Related fixes
Web apps
Axios get works with a URL string but ignores the object passed as the second argument
The server log shows a GET with no query string
axios.get takes a URL and an optional config object.
3 causes, each with a fixWeb apps
Expo app never leaves the splash screen
App shows the splash screen forever and no error appears
After SplashScreen.preventAutoHideAsync() the splash stays until you hide it yourself.
3 causes, each with a fixWeb apps
React Hook "useState" cannot be called at the top level, or in a function that is not a component
The lint points at a useState line inside a helper function, an onClick handler or the top of a module
The lint rule found a hook outside a component or custom hook.
3 causes, each with a fixWeb apps
React: Maximum update depth exceeded or Too many re-renders
Maximum update depth exceeded
React stops a component that sets state again and again without end.
3 causes, each with a fixWeb apps
React Native says the application has not been registered
Application has not been registered
The native side asks JavaScript to run an app name that JavaScript never registered.
3 causes, each with a fixWeb apps
TypeScript marks className as an error on React Native components
Property 'className' does not exist on type
React Native components have no className prop in their own types.
3 causes, each with a fix