如何从子抽屉导航转到父堆栈导航屏幕

时间:2018-11-10 14:42:05

标签: reactjs react-native react-navigation react-navigation-stack react-navigation-drawer

我的应用程序具有抽屉导航和堆栈导航。

export const AppDrawerNavigator = createDrawerNavigator(
{
    Home: {
      screen: Home,
      navigationOptions: {
        drawerIcon: ({ tintColor }) => (
          <Icon name="home" style={{ fontSize: 24, color: tintColor }} />
        )
      }
    },
    MyAccount: {
      screen: MyAccount,
      navigationOptions: {
        drawerIcon: ({ tintColor }) => (
          <Icon name="paper" style={{ fontSize: 24, color: tintColor }} />
        )
      }
    },
    Cashback: {
      screen: Cashback,
      navigationOptions: {
        drawerIcon: ({ tintColor }) => (
          <Icon name="pizza" style={{ fontSize: 24, color: tintColor }} />
        )
      }
    },
    Settings: {
      screen: Settings,
      navigationOptions: {
        drawerIcon: ({ tintColor }) => (
          <Icon name="settings" style={{ fontSize: 24, color: tintColor }} />
        )
      }
    },
    Campaigns: {
      screen: Campaigns,
      navigationOptions: {
        drawerIcon: ({ tintColor }) => (
          <Icon name="call" style={{ fontSize: 24, color: tintColor }} />
        )
      }
    }
  },
  {
    contentComponent: CustomDrawerComponent,
    contentOptions: { activeTintColor: "#60c2a2" }
  }
);

export const AppStackNavigator = createStackNavigator(
  {
    OnBoarding: {
      screen: OnBoardingContent
    },
    Login: {
      screen: Login
    },
    MarchantLogin: {
      screen: MarchantLogin
    },
    OTPScreen: {
      screen: OTPScreen
    },
    Home: {
      screen: Home
    },
    Drawer: {
      screen: AppDrawerNavigator
    }
  },
  {
    headerMode: "none",
    initialRouteName: "Drawer",
    navigationOptions: {
      headerVisible: false
    }
  }
);

然后我将其称为

render() {
    if (this.state.is_verified == "true") {
      return <AppStackNavigator />;
    } else {
      return <OnBoarding />;
    }
  }

我的问题是,当我单击“抽屉”按钮中的注销时,需要路由到OnBoarding组件。但是怎么可能呢? enter image description here

请帮助我解决这个问题,或者建议我一个更好的主意,因为我是这个堆栈的新手。谢谢。

0 个答案:

没有答案