question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Swipeable is not working on android

See original GitHub issue

So 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:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:20 (2 by maintainers)

github_iconTop GitHub Comments

26reactions
shhhiiiiicommented, Nov 25, 2019

This helps me to make swipeable working. https://aboutreact.com/swipe-gestures-not-working-in-android/

7reactions
lyair1commented, Apr 17, 2020

You’ll have to modify MainActivity.java:

Add:

import com.facebook.react.ReactActivityDelegate; import com.facebook.react.ReactRootView; import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;

@Override protected ReactActivityDelegate createReactActivityDelegate() { return new ReactActivityDelegate(this, getMainComponentName()) { @Override protected ReactRootView createRootView() { return new RNGestureHandlerEnabledRootView(MainActivity.this); } }; }

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found