反应导航自定义选项卡打字稿参数

时间:2021-03-29 20:19:37

标签: typescript react-native react-navigation

我正在使用带有 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;
........

0 个答案:

没有答案