In the app with react navigation 3.11.0, there are 3 tabs:
return createBottomTabNavigator(
{
Event: {
screen: EventStack,
navigationOptions: {
title: "Event",
},
},
Group: {
screen: GroupStack,
navigationOptions: {
title: "Group",
},
},
Contact: {
screen: ContactStack,
navigationOptions: {
title: "Contact",
},
},
}, bottomTabNavOptions,
{initialRouteName: Group} //<<<== did not work
);
I would like to set an initial tab on Group
. Tried
{initialRouteName: Group}
and
{initialTabNavigator: Group}
Both of them did not work. What is the right way to set initial tab?
The bottomTabNavOptions
is:
const bottomTabNavOptions = {
defaultNavigationOptions: ({ navigation }) => ({
tabBarIcon: ({ focused, tintColor }) => {
const { routeName } = navigation.state;
console.log("route name", routeName);
let iconName;
if (routeName === 'Event') {
iconName = `list-unordered`;
} else if (routeName === 'Contact') {
iconName = `person`;
} else if (routeName === 'Group') {
iconName = `organization`
}
return <Icon name={iconName} size={30} color={tintColor} type='octicon' />;
},
}),
tabBarOptions: {
activeTintColor: 'tomato',
inactiveTintColor: 'gray',
},
};
The createBottomTabNavigator
tab has two parameters. But you seem to be sending three parameters.
createBottomTabNavigator(RouteConfigs, BottomTabNavigatorConfig);
BottomTabNavigatorConfig:
createBottomTabNavigator(
{
Event: {
screen: EventStack,
navigationOptions: {
title: "Event",
},
},
Group: {
screen: GroupStack,
navigationOptions: {
title: "Group",
},
},
Contact: {
screen: ContactStack,
navigationOptions: {
title: "Contact",
},
},
},
{
initialRouteName: 'Group', <= you use string
bottomTabNavOptions,
}
);
Este artigo é coletado da Internet.
Se houver alguma infração, entre em [email protected] Delete.
deixe-me dizer algumas palavras