У меня есть следующие настройки навигации в response-navigation 3.x
const AuthStack = createStackNavigator(
{
Starter: {
screen: Starter,
},
SignIn: {
screen: Signin,
},
SignUp: {
screen: Signup,
},
ForgotPassword: {
screen: ForgotPassword,
},
SignUpSuccess: {
screen: RegisterSuccess,
},
ForgotPasswordSuccess: {
screen: ForgotPasswordSuccess,
},
},
{
initialRouteName: 'Starter',
headerMode: 'none',
},
);
const HomeStack = createStackNavigator(
{
HomeScreen,
},
{
headerMode: 'none',
},
);
const TabStack = createBottomTabNavigator(
{
Home: HomeStack,
....
},
{
initialRouteName: 'Home',
headerMode: 'none',
}
}
const MainNavigator = createStackNavigator(
{
TabStack,
...commonStack,
},
{
headerMode: 'none',
mode: 'modal',
},
);
const AppNavigator = createSwitchNavigator(
{
Auth: AuthStack,
App: MainNavigator,
},
{
initialRouteName: 'Auth',
},
);
const AppContainer = createAppContainer(AppNavigator);
Во время успешного входа в систему я делал следующее для сброса
const resetAction = StackActions.reset({
index: 0,
key: null, // using a nested router you'll also need to set key to null otherwise it'll keep looking into currently active navigator.
actions: [NavigationActions.navigate({routeName: 'TabStack'})],
});
this.props.navigation.dispatch(resetAction);
Но теперь я обновился, чтобы реагировать-navigation 4.x, но когда я запускаю приведенный выше код сброса, это дает мне исключение. В чем может быть проблема?
Error: There is no route defined for key TabStack. Must be one of: 'Starter','SignIn','SignUp','ForgotPassword','SignUpSuccess','ForgotPasswordSuccess'
This error is located at:
in Navigator (at createKeyboardAwareNavigator.js:12)
in KeyboardAwareNavigator (at SceneView.js:9)
in SceneView (at SwitchView.js:12)
in SwitchView (at createNavigator.js:80)
in Navigator (at createAppContainer.js:430)
in NavigationContainer (at main.js:38)
in RCTView (at main.js:37)
in RCTView (at Root.js:14)
in Root (at connectStyle.js:392)
in Styled(Root) (at main.js:36)
in Main (created by ConnectFunction)
in ConnectFunction (at App.js:91)
in ErrorBoundary (at App.js:90)
in Provider (at App.js:89)
in App (at renderApplication.js:40)
in RCTView (at AppContainer.js:101)
in RCTView (at AppContainer.js:119)
in AppContainer (at renderApplication.js:39)