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?
react-navigation uses this library for their drawer navigation. We have the same similar problem. The problem happens in v0.60.4. What's your RN version by the way?
My version is v0. 60.4 as well. I thought I was doing something wrong.
Facing the same issue. My version is v0.60.4 as well
+1
Works for me with v0.60.5
We are still having this issue on 0.61.0-rc2. Is this still one the radar for being fixed?
Yes same issue here, local code doesn't work with react navigation drawer, but here with Expo it does https://snack.expo.io/@netgfx/auth-flow-v3 any ideas?
apparently this was fixed in RN 0.61.1
I麓m using inside the Flatlist component, it's ok
I can say that in RN 0.61.1 it still exists.
The drawer opens, but it cannot be clicked away or swiped.
By the way, I'm not using Swipeable, but a regular createDrawerNavigator.
In version 4 of react-navigation, separate navigations
https://reactnavigation.org/docs/en/drawer-navigator.html#api
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;
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}
@MariShielaFurio Worked this solution for me.......Thank You
For the ones using react-native-navigation (RNN). You should instead follow this part of the doc:
https://software-mansion.github.io/react-native-gesture-handler/docs/getting-started.html#with-wix-react-native-navigation-https-githubcom-wix-react-native-navigation
Should be resolved.
For the ones using react-native-navigation (RNN). You should instead follow this part of the doc:
https://software-mansion.github.io/react-native-gesture-handler/docs/getting-started.html#with-wix-react-native-navigation-https-githubcom-wix-react-native-navigation
Amm, I am having the same issue. the gesture isn't working.
Also, I am using react-navigation - native.
New to react native, using Flat List.
Need help
Try following installation instructions at updated link
https://docs.swmansion.com/react-native-gesture-handler/docs
This helps me to make swipeable working.
https://aboutreact.com/swipe-gestures-not-working-in-android/
That was the solution in my case w/ Navigation 5. I noticed it worked after gradlew clean and then rebuild
Most helpful comment
This helps me to make swipeable working.
https://aboutreact.com/swipe-gestures-not-working-in-android/