我有一个已放入堆栈的登录屏幕。用户成功登录后,他被重定向到主屏幕,这是一个抽屉屏幕。抽屉屏幕的选项之一是注销,因此单击它的用户应该注销。以下是我的注销屏幕代码。我只是在 ui 中显示注销屏幕的进度条,但在useEffect
挂钩中,我正在调用以下方法
navigation.navigate({index: 0, routes: [{name: LOGIN_SCREEN}]});
但我收到一条错误消息You need to specify name or key when calling navigate with an object as the argument
,我被重定向到主屏幕。当我完全重新启动我的应用程序时,它只会移动到登录屏幕。我正在为名称键传递正确的值。
我的导航堆栈如下所示
<Stack.Navigator>
<Stack.Screen
name={LOGIN_SCREEN}
component={LoginScreen}
options={{headerShown: false}}
/>
<Stack.Screen
name={HOME_STACK_SCREEN}
component={DrawerStack}
options={{headerShown: false}}
/>...
我的抽屉组件如下
<Drawer.Navigator
drawerStyle={{backgroundColor: BLUE_COLOR_1}}
drawerContentOptions={{labelStyle: {color: '#FFF'}}}>
<Drawer.Screen
name={HOME_SCREEN}
component={Home}
options={{
...
}}
/>
<Drawer.Screen
name={LOGOUT_SCREEN}
component={Logout}
options={{
...
}}
/>