Complete the code to import the gesture handler root view component.
import { [1] } from 'react-native-gesture-handler';
The GestureHandlerRootView is the correct component to wrap your app for gesture handling.
Complete the code to wrap the app component with the gesture handler root view.
export default function App() {
return (
<[1] style={{ flex: 1 }}>
{/* Your app content */}
</[1]>
);
}Wrapping the app with GestureHandlerRootView enables gesture handling properly.
Fix the error in the gesture handler import statement.
import [1] from 'react-native-gesture-handler';
The correct syntax for importing a named export is using curly braces: { GestureHandlerRootView }.
Fill both blanks to create a tap gesture handler wrapping a button.
import { TapGestureHandler } from 'react-native-gesture-handler'; export default function TapExample() { return ( <TapGestureHandler onHandlerStateChange=[1]> <[2]> <Text>Tap me</Text> </[2]> </TapGestureHandler> ); }
The onHandlerStateChange expects a function, so () => console.log('Tapped!') is correct. The child must be a View or similar container.
Fill all three blanks to create a pan gesture handler that updates position state.
import { PanGestureHandler } from 'react-native-gesture-handler'; import React, { useState } from 'react'; import { View } from 'react-native'; export default function PanExample() { const [pos, setPos] = useState({ x: 0, y: 0 }); const onGestureEvent = event => { setPos({ x: event.nativeEvent.translationX, y: event.nativeEvent.[1] }); }; return ( <PanGestureHandler onGestureEvent={onGestureEvent} onHandlerStateChange=[2]> <View style={{ transform: [{ translateX: pos.x }, { translateY: pos.y }] }}> <View style={{ width: 100, height: 100, backgroundColor: '[3]' }} /> </View> </PanGestureHandler> ); }
translationY is the vertical translation property. The onHandlerStateChange can be an empty function if unused. The color 'red' is a valid background color.