Swipeable is not working on android
See original GitHub issueSo i’m trying to use the Swipeable component from react-native-gesture-handler. The thing is that it does nothing. Below is my code
App.js
import Swipeable from 'react-native-gesture-handler/Swipeable';
const RightActions = () => {
return (
<TouchableOpacity onPress={() => console.warn('works'))}>
<Icon name="md-trash" size={18} color={Colors.red} />
</TouchableOpacity>
);
};
const App = () => {
return (
<ScrollView>
...
{Object.keys(data).map(key => {
return (
<Swipeable key={key} renderRightActions={RightActions}>
<View>
<Text>Swipe left</Text>
</View>
</Swipeable>
);
});
</ScrollView>
);
};
export default App;
And here is my MainActivity.java as it is suggested.
package com.assosfood;
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 {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "assosfood";
}
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}
}
This is all done with react-native not with expo. What am i doing wrong?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:20 (2 by maintainers)
Top Results From Across the Web
react-native swipeable gesture not working on android?
Alright so, I found a solution by wrapping the swipeable in a gestureHandlerRootView. import { GestureHandlerRootView, Swipeable } from ...
Read more >Swipeable is not working on android? - React Native
here is my MessagesScreen.js import React from 'react'; import { FlatList, StyleSheet, View} from 'react-native'; import ListItem from '.
Read more >Is it me or does Expo's Swipeable not work in Android?
I think it might be an android thing. I moved my project over to a friends mac and tried it on the IOS...
Read more >Swipe Gestures not Working in Android- React Native ...
Solution of Swipe Gestures not Working in Android (React Native). To solve this you just have to add something in your MainActivity.java file....
Read more >Gestures | Jetpack Compose
Note: The scrollable modifier does not affect the layout of the element it is ... expected behaviour either might not happen or might...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

This helps me to make swipeable working. https://aboutreact.com/swipe-gestures-not-working-in-android/
You’ll have to modify MainActivity.java:
Add:
import com.facebook.react.ReactActivityDelegate;import com.facebook.react.ReactRootView;import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;@Overrideprotected ReactActivityDelegate createReactActivityDelegate() {return new ReactActivityDelegate(this, getMainComponentName()) {@Overrideprotected ReactRootView createRootView() {return new RNGestureHandlerEnabledRootView(MainActivity.this);}};}