我有3个标签,每个标签包含一组堆栈导航器。
const HomeNavigator = createStackNavigator();
const HomeStackNavigator = ({navigation, route}) => {
return (
<HomeNavigator.Navigator>
<HomeNavigator.Screen
name="Home"
component={Home}
/>
<HomeNavigator.Screen
name="Profile"
component={Profile}
/>
<HomeNavigator.Screen
name="Settings"
component={Settings}
/>
</HomeNavigator.Navigator>
);
};
const StoreNavigator = createStackNavigator();
const StoreStackNavigator = ({navigation, route}) => {
return (
<StoreNavigator.Navigator>
<StoreNavigator.Screen
name="OurStore"
component={Store}
/>
</StoreNavigator.Navigator>
);
};
const CommunityNavigator = createStackNavigator();
const CommunityStackNavigator = ({navigation, route}) => {
return (
<CommunityNavigator.Navigator>
<CommunityNavigator.Screen
name="Community"
component={Community}
/>
<CommunityNavigator.Screen
name="CommunityReply"
component={CommunityReply}
options={communityReplyOptions}
/>
<CommunityNavigator.Screen
name="AskCommunity"
component={AskCommunity}
/>
</CommunityNavigator.Navigator>
);
};
Tab Navigator
const MainNavigator = createBottomTabNavigator();
const MainTabNavigator = () => {
return (
<MainNavigator.Navigator
screenOptions={tabScreenOptions}
tabBarOptions={tabBarOptions}>
<MainNavigator.Screen
name="HomeTab"
component={HomeStackNavigator}
options={{tabBarLabel: 'Home'}}
/>
<MainNavigator.Screen
name="StoreTab"
component={StoreStackNavigator}
options={{tabBarLabel: 'Store'}}
/>
<MainNavigator.Screen
name="CommunityTab"
component={CommunityStackNavigator}
options={{tabBarLabel: 'Community'}}
/>
</MainNavigator.Navigator>
);
};
现在单击按钮时,我现在需要导航到“社区”选项卡导航器中的“社区回复”屏幕。可以帮我
反应导航版本
“ @ react-navigation / bottom-tabs”:“ ^ 5.8.0”
“ @ react-navigation / native”:“ ^ 5.7.3”
“ @ react-navigation / stack”:“ ^ 5.9.0”
答案 0 :(得分:1)
在这种情况下,下面的方法应该起作用:
this.props.navigation.navigate('CommunityTab', { screen: 'CommunityReply' });