这是我的代码。
App.js
这是我的MainActivity.java文件,正如包名所示。
我不明白正在发生什么,但有点沮丧。有没有人知道该怎么做?我的代码是我找到的一个教程的完全副本,所以我希望它能够工作。唯一的区别是我的项目使用了react-native,而教程使用了expo。
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;
这是我的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 of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "project";
}
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}
}
我不明白正在发生什么,但有点沮丧。有没有人知道该怎么做?我的代码是我找到的一个教程的完全副本,所以我希望它能够工作。唯一的区别是我的项目使用了react-native,而教程使用了expo。