HomeStackNavigator(stack)
---HomeTabsNavigator(Tab)
---FirstTab(stack)
---CreatePost(screen)
---Posts(Tab)
---Following(screen)
---Feed(
You can use the RootNavigation approach: https://reactnavigation.org/docs/navigating-without-navigation-prop/
First you create a file at your directory root called RootNavigation.js
that looks like this:
import * as React from 'react';
export const navigationRef = React.createRef();
export function navigate(name, params) {
navigationRef.current?.navigate(name, params);
}
Then you pass the navigationRef
as a ref to your NavigationContainer
:
import * as RootNavigation from './RootNavigation';
// ...
This allows you to navigate from anywhere.
Then you can do something like this in your Feed
screen:
const Feed = () => {
// ...