RNGH2 provides much simpler way to add gestures to your app. All you need to do is wrap the view that you want your gesture to work on with
GestureDetector, define the gesture and pass it to detector. That's all!
To demonstrate how you would use the new API, let's make a simple app where you can drag a ball around. You will need to add
react-native-gesture-handler (for gestures) and
react-native-reanimated (for animations) modules.
start shared value. We need it to store the position of the ball at the moment we grab it to be able to correctly position it later, because we only have access to translation relative to the starting point of the gesture.
Now you can just add
Ball component to some view in the app and see the results! (Or you can just check the code here and see it in action in the Example app.)