这是我的代码。
应用程序.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;
Run Code Online (Sandbox Code Playgroud)
这是我的 MainActivity.java,如包所示。
package com.project;
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 …Run Code Online (Sandbox Code Playgroud)