|
1 | 1 | import type {EventMapCore, NavigationProp, NavigationState, ParamListBase} from '@react-navigation/native'; |
2 | | -import {useNavigation} from '@react-navigation/native'; |
| 2 | +import {useNavigation, useRoute} from '@react-navigation/native'; |
3 | 3 | import {createStackNavigator} from '@react-navigation/stack'; |
4 | 4 | import React, {useEffect, useMemo, useState} from 'react'; |
5 | 5 | import {View} from 'react-native'; |
@@ -53,11 +53,12 @@ type DebugTabNavigatorProps = { |
53 | 53 | function DebugTabNavigator({id, routes}: DebugTabNavigatorProps) { |
54 | 54 | const styles = useThemeStyles(); |
55 | 55 | const theme = useTheme(); |
56 | | - const navigation = useNavigation<NavigationProp<Record<string, void>>>(); |
| 56 | + const navigation = useNavigation<NavigationProp<Record<string, unknown>>>(); |
57 | 57 | const {translate} = useLocalize(); |
58 | 58 | const [currentTab, setCurrentTab] = useState(routes.at(0)?.name); |
59 | 59 | const defaultAffectedAnimatedTabs = useMemo(() => Array.from({length: routes.length}, (v, i) => i), [routes.length]); |
60 | 60 | const [affectedAnimatedTabs, setAffectedAnimatedTabs] = useState(defaultAffectedAnimatedTabs); |
| 61 | + const routeData = useRoute(); |
61 | 62 |
|
62 | 63 | useEffect(() => { |
63 | 64 | // It is required to wait transition end to reset affectedAnimatedTabs because tabs style is still animating during transition. |
@@ -98,7 +99,7 @@ function DebugTabNavigator({id, routes}: DebugTabNavigatorProps) { |
98 | 99 | const {icon, title} = getIconAndTitle(route.name, translate); |
99 | 100 |
|
100 | 101 | const onPress = () => { |
101 | | - navigation.navigate(route.name); |
| 102 | + navigation.navigate(routeData.name, {...routeData?.params, screen: route.name}); |
102 | 103 | setCurrentTab(route.name); |
103 | 104 | }; |
104 | 105 |
|
|
0 commit comments