我升级到了react导航V5,我很困惑如何让抽屉工作。我以前有一个定制抽屉,但现在我只是想让一个样品抽屉工作。
我正试图用this.props.navigation.dispatch(DrawerActions.toggleDrawer())打开抽屉
The action 'TOGGLE_DRAWER' was not handled by any navigator.
Is your screen inside a Drawer navigator?
以下是相关档案:
MessagesStackRouter.js
import { NavigationContainer }
我有一个应用程序与登录页面,我不希望抽屉出现在这个页面上。只有接下来的那些。我想我应该创建两个堆栈导航器。抽屉导航器将包装其中一个,但不包装另一个。我使用的是我曾经使用过的@react导航/折叠器库:
App.js
// Have both navigators at the root
render() {
return (
[
<NavigationContainer>
<DrawerNavigator extraData={{handleLogin:this.handleLogin, handleLogout:this.handleL
我想像这样导航(当我没有做抽屉的时候,它工作得很好):
<Button onPress={() => this.props.navigation.navigate('Projects')}></Button>
但在添加抽屉后,按下按钮后,我得到一个错误,如下所示:
console.error: The action 'NAVIGATE' with payload '{"name":"Projects"}' was not handled by any navigator.
这是我的抽屉