android - 如何使用 MyDrawer 功能?
问题描述
[我的抽屉功能不起作用,所以我尝试添加 onPress={() => navigation.openDrawer() 功能以查看它是否有效,但似乎功能“openDrwaer”不存在,即使它在文档中@react-navigation/drawer][1]
import {useNavigation} from '@react-navigation/native';
import React from 'react';
import Icon from 'react-native-vector-icons/Feather';
import {Button, Container} from './styles';
import {createDrawerNavigator} from '@react-navigation/drawer';
import SignIn from '../../pages/SignIn';
const Drawer = createDrawerNavigator();
function MyDrawer() {
return (
<Drawer.Navigator>
<Drawer.Screen name="log-out" component={SignIn} />
</Drawer.Navigator>
);
}
const Header: React.FC = () => {
const navigation = useNavigation();
return (
<Container>
<MyDrawer />
<Button onPress={navigation.goBack}>
<Icon name="arrow-left" size={30} />
</Button>
<Button onPress={() => navigation.openDrawer()} >
<Icon name="menu" size={30} />
</Button>
</Container>
);
};
export default Header;
解决方案
推荐阅读
- android - 当我单击按钮时,Android 回收站视图未更新
- r - 对具有相同名称的列求和
- haskell - 单子的运算符关联性、关联律和值依赖性如何结合在一起?
- .htaccess - .htaccess 并按大小写区分查询字符串
- java - Apache POI,在同一行中将文本左对齐,其他文本右对齐
- r - 根据动态列数和名称对数据框进行子集化
- python - 从txt文件中提取数据
- c++11 - 多重定义错误(collect2:error:ld returned 1 exit status)
- java - 飞溅前的Android白屏
- db2 - 有什么方法可以将 VIP 移到 DB2 TSAMP 环境中的另一个资源组?