'React Navigation Custom Tab Typescript Params
I am developing projects with Typescript language with React Native library. While creating a Custom Tab Bar, parameters include state, descriptors, and navigation. What should I specify as a type with this?
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;
........
Solution 1:[1]
- Top Tab Navigator = "MaterialTopTabBarProps"
- Bottom Tab Bar = "BottomTabBarProps"
import { BottomTabBarProps } from '@react-navigation/bottom-tabs';
import { MaterialTopTabBarProps } from '@react-navigation/material-top-tabs';
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
