首页 > 解决方案 > 在 React Native Navigation 中更改“SingleScreenApp”的主屏幕

问题描述

我是 React Native 的新手,我想react-native-navigation通过wix进行测试

我有一个带抽屉的 SingleScreenApp。见下文 :

Navigation.startSingleScreenApp({
  screen: {
    screen: 'example.HomeScreen', 
    title: 'Home', 
    navigatorStyle: {}, 
    navigatorButtons: {} 
  },
  drawer: {
    // optional, add this if you want a side menu drawer in your app
    left: {
      screen: 'example.LefMenu', 
      passProps: {}, 
      disableOpenGesture: false, 
      fixedWidth: 500 
    },
    style: {
      drawerShadow: true, 
      contentOverlayColor: 'rgba(0,0,0,0.25)', 
      leftDrawerWidth: 50, 
      rightDrawerWidth: 50 
    },
    type: 'MMDrawer', 
    animationType: 'door',
    disableOpenGesture: false 
  },
  passProps: {}, 
  animationType: 'slide-down' 
});

为了具有类似菜单的行为,我想更改 SingleScreenApp 的主屏幕(通过单击按钮或其他交互)。

我坚持要更改/替换主屏幕,而不是推送或显示模式。

我应该用根屏幕不同的屏幕启动另一个 SingleScreenApp 吗?我应该使用“ resetTo ”方法吗?在性能方面什么是最好的?

非常感谢 !

标签: react-nativereact-native-navigationwix-react-native-navigation

解决方案


您确实想使用resetTo()。这将弹出所有当前推送的屏幕并用新的屏幕替换当前的根屏幕。


推荐阅读