What is the purpose of the React Native Gesture Handler library?
It provides improved gesture handling and touch interactions in React Native apps, offering better performance and native-like gestures compared to the default gesture system.
Click to reveal answer
beginner
Which component from Gesture Handler is used to detect a tap gesture?
The <TapGestureHandler> component detects tap gestures, allowing you to respond when the user taps on a view.
Click to reveal answer
beginner
How do you wrap your app to enable Gesture Handler in React Native?
You wrap your app's root component with <GestureHandlerRootView> to enable gesture handling across the app.
Click to reveal answer
intermediate
What is the role of the onGestureEvent prop in Gesture Handler components?
It is a callback function that receives gesture events, allowing you to respond to gesture state changes like start, active, and end.
Click to reveal answer
intermediate
Why is Gesture Handler preferred over React Native's default gesture system?
Because it uses native gesture handling under the hood, it offers smoother animations, better gesture recognition, and fewer gesture conflicts.
Click to reveal answer
Which component should wrap your app to enable Gesture Handler?
A<GestureHandlerRootView>
B<GestureDetector>
C<GestureHandlerProvider>
D<GestureWrapper>
✗ Incorrect
The component wraps the app root to enable gesture handling.
Which Gesture Handler component detects a swipe or pan gesture?
A<PinchGestureHandler>
B<TapGestureHandler>
C<LongPressGestureHandler>
D<PanGestureHandler>
✗ Incorrect
detects dragging or swiping gestures.
What prop do you use to listen to gesture state changes?
AonTap
BonGestureEvent
ConPress
DonSwipe
✗ Incorrect
The onGestureEvent prop receives gesture event updates.
Gesture Handler improves gesture performance by:
AUsing native gesture recognition
BUsing JavaScript timers
CDisabling gestures
DUsing CSS animations
✗ Incorrect
It uses native gesture recognition for smoother and more reliable gestures.
Which of these is NOT a Gesture Handler component?
A<TapGestureHandler>
B<LongPressGestureHandler>
C<SwipeGestureHandler>
D<PinchGestureHandler>
✗ Incorrect
does not exist; swipes are detected with .
Explain how to set up Gesture Handler in a React Native app and why it is important.
Think about the root wrapper and native gesture benefits.
You got /4 concepts.
Describe how you would detect and respond to a tap gesture using Gesture Handler.
Focus on the component and event handling.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of wrapping your React Native app with GestureHandlerRootView?
easy
A. To enable gesture detection and handling throughout the app
B. To style the app's background color
C. To improve app performance by caching views
D. To add navigation capabilities between screens
Solution
Step 1: Understand the role of GestureHandlerRootView
This component is required to wrap the app so that gesture detection works properly across all child components.
Step 2: Differentiate from other purposes
Styling, performance caching, or navigation are unrelated to GestureHandlerRootView's function.
Final Answer:
To enable gesture detection and handling throughout the app -> Option A
Hint: Always wrap app with GestureHandlerRootView [OK]
Common Mistakes:
Using onPress instead of onActivated
Thinking View can't detect gestures
Assuming size is too small
5. You want to detect both tap and long press gestures on the same box using react-native-gesture-handler. Which approach correctly integrates both handlers?
hard
A. Use only TapGestureHandler with a long delay prop
B. Use PanGestureHandler instead for both tap and long press
C. Wrap the box in two sibling gesture handlers without nesting
D. Nest LongPressGestureHandler inside TapGestureHandler and handle callbacks separately
Solution
Step 1: Understand gesture handler nesting
To detect multiple gestures on the same view, nest handlers so gestures can be recognized distinctly.
Step 2: Evaluate options
Using only TapGestureHandler can't detect long press, siblings won't work well on same view, PanGestureHandler is for drag gestures.
Final Answer:
Nest LongPressGestureHandler inside TapGestureHandler and handle callbacks separately -> Option D