Reputation: 1
I have noticed that when I am in clicking reload the navigator opening the home screen.
there is a way to stay on the same screen when the user clicks reload?
this is my navigation code:
AuthNavigation.js
import { createStackNavigator } from 'react-navigation-stack'
import WebHome from '../screens/WebHome'
import EditUserHome from '../screens/EditUserHome'
import EditUserInfo from '../screens/EditUserInfo'
const AuthNavigation = createStackNavigator(
{
WebHome: { screen: WebHome},
EditUserHome: { screen: EditUserHome},
EditUserInfo: { screen: EditUserInfo}
},
{
initialRouteName: 'WebHome',
headerMode: 'none'
}
)
export default AuthNavigation
AppNavigation.js:
import { createStackNavigator } from 'react-navigation-stack'
import Home from '../screens/Home'
const AppNavigation = createStackNavigator(
{
Home: { screen: Home }
},
{
initialRouteName: 'Home'
}
)
export default AppNavigation
index.js:
import { createSwitchNavigator, createAppContainer } from 'react-navigation'
import Initial from '../screens/Initial'
import AuthNavigation from './AuthNavigation'
import AppNavigation from './AppNavigation'
const SwitchNavigator = createSwitchNavigator(
{
Initial: Initial,
Auth: AuthNavigation,
App: AppNavigation
},
{
initialRouteName: 'Initial'
}
)
const AppContainer = createAppContainer(SwitchNavigator)
export default AppContainer
Upvotes: 0
Views: 737
Reputation: 31
when I am in clicking reload the navigator opening the home screen
If you're talking about reloading the app through developer tools - I'm afraid not. The app will reset itself on each reload. As though it were the first time you've opened it.
To get around this while developing you can change the initialRouteName
value, or force a navigation by using the regular navigate API navigation.navigate('<route_name>')
.
Upvotes: 1