我在Stack Navigator中嵌套了一个Drawer Navigator,它工作得很好,当我滑动它的时候就会打开它,我想在它上面放一个菜单图标,当它被按下时,抽屉就会打开。我尝试的每个方法都以navigation can't be found错误结束。
下面是我的代码:
export class App extends Component {
.....
function DrawerNav() {
return (
<Drawer.Navigator
drawerType="front"
initialRouteName="Main" drawerPosition="right">
<Drawer.Screen name="Main" component={MainScreen} />
<Drawer.Screen name="Wallet" component={WalletScreen} />
<Drawer.Screen name="Appointments" component={Appointments} />
</Drawer.Navigator>
);}
return (
<Provider store={store}>
<NavigationContainer>
<Stack.Navigator initialRouteName="Menu">
<Stack.Screen name="Menu" component={DrawerNav} />
<Stack.Screen name="Add" component={AddScreen} navigation={this.props.navigation}/>
<Stack.Screen name="Save" component={SaveScreen} navigation={this.props.navigation}/>
</Stack.Navigator>
</NavigationContainer>
</Provider>
)}}当我按下这个图标时,我想打开和关闭抽屉:
<MaterialIcons name='menu' size={28} onPress={??} />
发布于 2021-08-08 14:06:15
https://stackoverflow.com/questions/68701287
复制相似问题