I have navigator (X
) which holds a screen, lets call it N
, and another navigator, Y
. I need to travel from a screen in navigator Y
, to screen N
in the root navigator. How would I go about doing this using react navigation 6?
Code for the root router:
<NavigationContainer>
<Tabs.Navigator>
<Tabs.Screen component={HomeRouter} name="HomeTab" />
</Tabs.Navigator>
</NavigationContainer>
Code for Home router (Navigator X
):
<NavigationContainer independent={true}>
<Stack.Navigator initialRouteName={"Home"}>
<Stack.Screen name="Home" component={Home} />
<Stack.Screen name="Post" component={Post} />
<Stack.Screen name="Profile" component={Account} />
</Stack.Navigator>
</NavigationContainer>
Code for profile router (Navigator Y
):
<NavigationContainer independent={true} theme={MyTheme}>
<Stack.Navigator>
<Stack.Screen name="MainProfile" component={MainAccountPage} />
</Stack.Navigator>
</NavigationContainer>
I need to navigate from the MainAccountPage
screen in navigator Y
to the Post
screen in navigator X
.