index.js有这样的代码,它有StackNavigator
const App = StackNavigator({
Home: {
screen: Home,
},
});
const AppNavigator = StackNavigator(
{
Login: {
screen: SignIn,
},
SignUp: {
screen: SignUp,
},
myApp: { screen: App },
},
{
gestureEnabled: false,
headerMode: 'none',
},
);
我正在登录并推送到myApp路线,
this.props.navigation.dispatch(
NavigationActions.reset({
index: 0,
key: null,
actions: [NavigationActions.navigate({ routeName: 'myApp' })]
})
);
现在所有导航推送和流行goback工作我正在尝试切除那些无法正常工作。
从家里我想登录界面。我正在进行退出行动
logoutPressed() {
const resetAction = NavigationActions.reset({
index: 0,
actions: [NavigationActions.navigate ({ routeName:
'Login' })],
});
this.props.navigation.dispatch(resetAction);
}
错误:routeName: 'Login' not found in StackNavigator
是什么问题。如何解决。
答案 0 :(得分:1)
您必须按如下方式编写堆栈导航器
const App = StackNavigator({
Home: {
screen: Home,
},
Login: {
screen: SignIn,
},
});
App StackNavigator没有登录路线,您需要在其导航中设置路线名称