I've a custom navigator because I wanted to go back to the previous screen using a back swipe gesture. Below is the code of the main file from where the navigators are called.
const MainSwipeStack = () => {
return(
<Navigator>
<Route name="LoggedOutHome" component={LoggedOutHome} />
<Route name="SignUp" component={SignUp} />
<Route name="SignupUsername" component={SignupUsername} />
<Route name="Login" component={Login} />
</Navigator>
);
}
export default createSwitchNavigator({
SwipeStack: {screen: MainSwipeStack},
TabHolder: {screen: TabHolder}
}, {
initialRouteName: 'SwipeStack',
headerMode: 'none',
});
And below is the link to the Navigator.js
code. (I didn't add the code here because it's a long code.)
https://gist.github.com/shubham6996/a4197d2d0b664d4aabe01091cac6c91e
And the TabHolder
takes me to the screen which has createBottomTabNavigator
.
So, now I'm not able to navigate from the Login
screen to TabHolder
stack.
How can I navigate from Login
which is in a custom navigator to TabHolder
stack?
seems navigation props is not there,
try this
in login and yes do import also
Components which are not directly used in navigators do not have navigation prop by default.
So you need to either pass it as normal props like this,
but in stack we dont have navigation prop so we can not pass like this (or idk if we have prop there....)
so alternate option is
withNavigation
andwithNaviagtionFocus
as shown abovefind details about withNavigation