React Native how to programmatically navigate to a stack screen that is on a tab navigator

Viewed 1615

I have searched tirelessly for an answer to this issue.

I have a Tab Navigator:

const AppNavigator = () => {
return (
<Tab.Navigator initialRouteName="Search">
  <Tab.Screen
    name="Home"
    children={() => <HomeScreen />}
    options={{
      tabBarIcon: ({ color, size }) => (
        <MaterialCommunityIcons name="home" color={color} size={size} />
      ),
    }}
  />
  <Tab.Screen
    name="Search"
    children={() => <SearchContainerNavigator />}
    options={{
      tabBarIcon: ({ color, size }) => (
        <FontAwesome5 name="search" color={color} size={size} />
      ),
    }}
  />
  <Tab.Screen
    name="Feedback"
    children={() => <FeedbackScreen />}
    options={{
      tabBarIcon: ({ color, size }) => (
        <MaterialCommunityIcons name="email" color={color} size={size} />
      ),
    }}
  />
</Tab.Navigator>
);
};

And this Stack navigator:

const SearchContainerNavigator = () => (
<Stack.Navigator screenOptions={{ headerShown: false}} initialRouteName="SearchSelect">
    <Stack.Screen name="SearchSelect" component={SearchSelectScreen} />
    <Stack.Screen name="AircraftSearch" component={AircraftSearchScreen} />
    <Stack.Screen name="AircraftResults" component={AircraftResultsScreen} />
    <Stack.Screen name="AircraftDetail" component={AircraftDetailScreen} />
    <Stack.Screen name="BrandSearch" component={BrandSearchScreen} />
    <Stack.Screen name="BrandResults" component={BrandResultsScreen} />
    <Stack.Screen name="BrandDetail" component={BrandDetailScreen} />
    <Stack.Screen name="Favourites" component={FavouritesScreen} />
</Stack.Navigator>
)

My issue is how do I programmatically navigate from HomeScreen tab to the AircraftDetailsScreen on the Search Tab??

Thanks in advance.

EDIT:

HomeScreen is a class.

 handleAircraftSelect = (aircraft_id) => {
 this.props.navigation.navigate("Search", {
   screen: "AircraftDetail",
   params: { id: aircraft_id },
 });
 };
1 Answers
Related