我有一个应用程序,必须使用堆栈和标签进行大量导航。
所以我有这些堆栈:
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)
问题:每当我单击AccountPage
中的“注销”按钮时,RN都会抛出一个错误,指出没有定义为“登录名”的路由(这是因为我们在帐户堆栈中并且在那里没有定义为Login
)。
现在,我如何将用户从内部堆栈(即Routes
)重定向到根堆栈(即Accounts
)中的登录屏幕?