1

我有一个应用程序,我必须使用堆栈和选项卡进行大量导航。

所以我有这些堆栈:

Routes (StackNavigation)
  - Start 
  - Login
  - ProtectedRoutes (TabNavigator)
    // Depending on which type of user is logged in
    // I have to change the number of tabs that are displayed
    - Reports (StackNavigator)
      - ...More Routes
    - Payments (StackNavigator)
      - ...More Routes
    - Invoices (StackNavigator)
      - ...More Routes
    - Account  (StackNavigator)
      - AccountPage
        // The account page has a button "Logout", 
        // when clicked removes all the user data
        // and should redirect to Login screen 
        // from Routes stack (The Root Stack)

问题:每当我点击 Logout 中的按钮时AccountPage,RN 都会抛出一个错误,指出没有定义为 Login 的路由(这是因为,我们在帐户堆栈中,并且没有任何定义在Login那里)。

现在,我如何将用户重定向回根堆栈中的登录屏幕,即Routes从内部堆栈即Accounts

4

0 回答 0