react-navigation lecture2
安装:yarn add react-navigationor with npmnpm install --save react-navigationyarn add react-native-gesture-handlerreact-native link react-native-gesture-handlerandroid:MainActivity.java:package ...
·
安装:
yarn add react-navigation
or with npm npm install --save react-navigation
yarn add react-native-gesture-handler
react-native link react-native-gesture-handler
android:
MainActivity.java:
package com.reactnavigation.example;
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 {
@Override
protected String getMainComponentName() {
return "Example";
}
+ @Override
+ protected ReactActivityDelegate createReactActivityDelegate() {
+ return new ReactActivityDelegate(this, getMainComponentName()) {
+ @Override
+ protected ReactRootView createRootView() {
+ return new RNGestureHandlerEnabledRootView(MainActivity.this);
+ }
+ };
+ }
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
Creating a stack navigator: 创建一个导航栏
const AppNavigator = createStackNavigatore({
Home: {
screen: HomeScreen
}
});
export default createAppContainer(AppNavigator);
更多推荐


所有评论(0)