You need a react-native-gesture-handler
module to swipe
.
You can run
yarn add react-native-gesture-handler
OR
npm install --save react-native-gesture-handler
AND react-native link react-native-gesture-handler
Update your MainActivity.java
file (or wherever you create an instance of ReactActivityDelegate
), so that it overrides the method responsible for creating ReactRootView
instance and then use the root view wrapper provided by this library. Do not forget to import ReactActivityDelegate
, ReactRootView
, and RNGestureHandlerEnabledRootView
:
package com.swmansion.gesturehandler.react.example;
import com.facebook.react.ReactActivity;
+ import com.facebook.react.ReactActivityDelegate;
+ import com.facebook.react.ReactRootView;
+ import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
public class MainActivity extends ReactActivity {
@Override
protected String getMainComponentName() {
return "Example";
}
+ @Override
+ protected ReactActivityDelegate createReactActivityDelegate() {
+ return new ReactActivityDelegate(this, getMainComponentName()) {
+ @Override
+ protected ReactRootView createRootView() {
+ return new RNGestureHandlerEnabledRootView(MainActivity.this);
+ }
+ };
+ }
}
For more information, see