I have created a switch navigator between the auth and app screens. The first time it worked fine but after when we use the app for some time it shows a random screen before splash when we open the application again. On Android, it works fine.
Here's my code for app navigator:
// Authentication Screens Stack
const AuthStack = createStackNavigator(
{
LoginScreen: LoginScreen,
// Login With Instagram Screen
LoginInstagram: LoginInstagramScreen,
RegisterScreen: RegisterScreen,
ForgotPasswordScreen: ForgotPasswordScreen
},
{
// See https://reactnavigation.org/docs/en/stack-navigator.html#stacknavigatorconfig
headerMode: 'none',
}
);
// Main App Stack from Home Screens
const AppStack = createStackNavigator(
{
DrawerScreen: DrawerNavigator,
},
{
// See https://reactnavigation.org/docs/en/stack-navigator.html#stacknavigatorconfig
headerMode: 'none',
}
);
// Switch Navigator Between Authentication and Home Screens
const SwitchStack = createSwitchNavigator(
{
Auth: AuthStack,
App: AppStack,
},
{
// See https://reactnavigation.org/docs/en/stack-navigator.html#stacknavigatorconfig
headerMode: 'none',
}
);
export default createAppContainer(SwitchStack)
Here's code for app.js
render() {
return (
/**
* @see https://github.com/reduxjs/react-redux/blob/master/docs/api/Provider.md
*/
<Provider store={store}>
{/**
* PersistGate delays the rendering of the app's UI until the persisted state has been retrieved
* and saved to redux.
* The `loading` prop can be `null` or any react instance to show during loading (e.g. a splash screen),
* for example `loading={<SplashScreen />}`.
* @see https://github.com/rt2zz/redux-persist/blob/master/docs/PersistGate.md
*/}
<PersistGate loading={<SplashScreen />} onBeforeLift={this.onBeforeLift} persistor={persistor}>
{this.state.gateLifted ? <RootScreen LoginStatus={this.state.isLogin} /> : <SplashScreen />}
{/* {<RootScreen LoginStatus={this.state.isLogin} />} */}
</PersistGate>
</Provider>
)
}
I have seen many apps showing this type of behaviour but not found anything about it. Any help would be appreciated. Thanks in advance