typescript - 反应导航自定义选项卡打字稿参数
问题描述
我正在使用带有 React Native 库的 Typescript 语言开发项目。创建自定义标签栏时,参数包括状态、描述符和导航。我应该用这个指定什么类型?
import { View, Text, TouchableOpacity } from 'react-native';
function MyTabBar({ state, descriptors, navigation }) {
const focusedOptions = descriptors[state.routes[state.index].key].options;
if (focusedOptions.tabBarVisible === false) {
return null;
}
return (
<View style={{ flexDirection: 'row' }}>
{state.routes.map((route, index) => {
const { options } = descriptors[route.key];
const label =
options.tabBarLabel !== undefined
? options.tabBarLabel
: options.title !== undefined
? options.title
: route.name;
........
解决方案
- 顶部选项卡导航器 = "MaterialTopTabBarProps"
- 底部标签栏 = "BottomTabBarProps"
import { BottomTabBarProps } from '@react-navigation/bottom-tabs';
import { MaterialTopTabBarProps } from '@react-navigation/material-top-tabs';```
推荐阅读
- sitecore - Sitecore SXA:您的网站已以线框模式导出
- postgresql - 如何使用 PostgreSQL 的 UTC 偏移量获取 ISO 格式的时间?
- c++11 - 在虚拟方法中推断“this”的类型名
- php - 为什么mysql查询返回零值?
- sql - 用于替换特定列中部分字符串的 REPLACE 函数
- r - 将数据框与一列中的列表保存为制表符分隔的单个条目“.txt”文件
- php - 从 localhost 连接到在线数据库时,用户 'totallig_root'@'197.210.64.73' 的访问被拒绝(使用密码:YES)
- r - R 在地图函数中继续 t.test,尽管没有足够的观察值
- c++ - 如何在 NGINX 服务器上运行 C++ CGI 脚本
- java - 为什么我的拦截器的 Spring 处理程序在配置登录身份验证时工作错误?感到不解