Open Homitag14 opened 1 year ago
This can be done as below:
tabBarRef
for your bottom navigator: export const tabBarRef = createRef()
Add it to your bottom navigator:
<CurvedBottomBar.Navigator
ref={tabBarRef}
...
>
...
</CurvedBottomBar.Navigator>
In your stack navigator that is nested inside the bottom navigator, import the tabBarRef
and add a useFocusEffect
that hides the bottom navigator when you are on a route that needs the bottom tab to be hidden. Note that since the stack navigator is nested inside the bottom navigator, you get navigation
, route
objects as props in the stack navigator.
import { tabBarRef } from 'path-to-bottom-navigator'
import {
getFocusedRouteNameFromRoute,
useFocusEffect,
} from '@react-navigation/native'
useFocusEffect(() => {
const routeName = getFocusedRouteNameFromRoute(route)
if (
[
'route-with-bottom-tab-hidden-1',
'route-with-bottom-tab-hidden-2',
...
].includes(routeName)
) {
tabBarRef.current.setVisible(false)
} else {
tabBarRef.current.setVisible(true)
}
})
@draturi95 where should I get the route variable from? I did that useFocusEffect inside the definition of the stackNavigator, but couldn't find the route variable.
@LuamLeite
As edited above,
Since the stack navigator is nested inside the bottom navigator, you get navigation
, route
objects as props in the stack navigator.
@LuamLeite
Hi you, can you share the bottom menu code to handle this problem?
Thank you.
can someone explain better that example or have one done
Why do you have to do this when you can have them on the same hierarchy as this tab navigator?
same here ...