I have a set of stack navigators in each tabs of tab navigator. When I log the state of the navigation, within any component, i get following payload,
import { useNavigation } from "@react-navigation/native";
const navigation = useNavigation();
console.log(navigation.getState())
// console.log result
{
"index": 1,
"key": "stack-5XO-MpDH2pNKUKeoe1hoF",
"routeNames": [
"CHome",
"CDetailPage",
"CSPage"
],
"routes": [
{
"key": "CHome-S99nM512YJSMqjIHj7lPt",
"name": "CHome",
"params": [
null
]
},
{
"key": "CSPage-ugZ8nf9H0B_H8jfrc1KNi",
"name": "CSPage",
"params": [
null
]
}
],
"stale": false,
"type": "stack"
}
From here, I can get the active route name and params, but how can i get in which stack does the current screen exists ?
<Tab.Navigator>
<Tab.Screen>
name="Home" <-------- If the above stack is this, then how to get this name withing any active screen( or from header ) ?
component={HomeStack}
<Tab.Screen>
Is it possible to get the active tab name from a screen of a stack navigator ?