Reputation: 316
In my React Native project I want users to navigate to the Login page. And, at the login page, user can fill the inputs to log in. Then, if log in process is successful, user should navigate back to the Homepage.
I am doing all the navigations with this.props.navigation.navigate function. But at the login page, the navigate function doesn't work as I expected. It works like the goBack function. By that I can't update homepage's state.
What should i do for navigate function to work as the way it works always ?
Upvotes: 1
Views: 125
Reputation: 4879
Modal
. (Recommend)Wrap your homeStack
and AuthStack
using createStackNavigation
with a Modal
option. or use createSwitchNavigation
.
const MainStack = createStackNavigator(
{
Home: {
screen: HomeStack,
},
Auth: {
screen: AuthStack,
},
},
{
mode: 'modal',
}
);
OR
It works as goBack
even though you use navigate
in stackNavigation if screen is stacked already as your process home->login->home. Thus, using modal
can be a one of simple and cool way.
Modal: https://reactnavigation.org/docs/en/modal.html
Upvotes: 2