I have something like:
const Tab = createBottomTabNavigator<DefaultTabbedParamList>();
const DefaultTabbedNavigation = () => {
return (
<>
<Tab.Navigator initialRouteName='Home' screenOptions={{
unmountOnBlur: true,
}}>
<Tab.Screen name="Home" component={HomeScreen} options={{
...defaultOptions,
tabBarIcon: ({ color, size, focused }) => (
<Icon as={Ionicons} name={`home${focused ? `` : `-outline`}`} size={size} color={color} />
)
}} />
...
</Tab.Navigator>
</>
);
}
When a user clicks to a detail view from Home
(or any other tab), I want to load a detail view with the currently selected tab remaining.
What’s the correct approach to handle this?
One idea I had was to have a StackNavigator
in HomeScreen
that includes a Detail
screen. But it seems repetitive to do for every screen, no?
3
Answers
How about this?
Yeah, you’ll likely want to define a
StackNavigator
for each tab. It’s a bit repetitive, but that’s been a theme of my experience with RN.You can do something like:
You can do something like this :-
Note:- To use this kind of approch your routeName and componentName should be same.