my app should have a login screen, with Google, so when signed in it goes to the menu screen.
in order to not go back to the login screen when pressing the back button, after getting to the menu screen after the authentication. I've separated the stacks one for the login and one for the other screens
in App.js:
const AuthStack = createStackNavigator({
LoginSplashScreen: LoginSplashScreen
});
const AppStack = createStackNavigator({
MenuScreen:MenuScreen,
DetailsScreen: DetailsScreen,
PhotoScreen: PhotoScreen,
DocumentScreen: DocumentScreen,
AudioScreen: AudioScreen,
ScheduleScreen: ScheduleScreen,
SettingsScreen: SettingsScreen,
FilesScreen: FilesScreen,
GalleryScreen: GalleryScreen
});
const Root= createAppContainer(createSwitchNavigator(
{
AuthStack:AuthStack,
AppStack:AppStack
},
{
initialRouteName: 'AuthStack',
}
));
export default class App extends React.Component {
render() {
return (
<Root/>
)
}
}
so in the LoginSplashScreen after authenticating I used this code to navigate:
this.props.navigation.navigate('AppStack', {
signedIn: true,
name: result.user.name,
photoUrl: result.user.photoUrl
});
the navigation works great, but the parameters 'name','signedIn','photoUrl' do not pass in fact, when alerting
Alert.alert('',JSON.stringify(this.props.navigation.state.params))
on the menu screen(second stack), it is empty
what am I doing wrong?
why my parameters aren't passing? because I might need another drawer navigation .
is there a way to set global parameters for all screens in the application?
Is there a better way to avoid pressing back on menu Screen and not getting the login screen?
EDIT:
I managed to solve this specific problem with setting a global parameter with:
global.param= result.param;
but, I still need an answer for passing between 2 separated stacks