'Insert' (login) screen before tabnavigator routing

I am looking for help to insert a screen (login) before entering in the tab navigation system (app generated using tab template). Login screen must be the first screen (after splash) and after tapping login button it shows the tabs and tab navigation

Thanks a lot


In your RootStackNavigator in RootNavigation.js, you can add a new sceen Login and set the initialRouteName to Login :

const RootStackNavigator = StackNavigator(
    Login: { screen: Login },
    Main: {
      screen: MainTabNavigator
    navigationOptions: () => ({
      headerTitleStyle: {
        fontWeight: "normal"
      initialRouteName: "Login",

Then, to navigate to you main tab navigation, in the Login screen you can navigate with the navigation props

class LoginScreen extends React.Component {
  render() {
    return (
      <ScrollView style={styles.container}>
        <Text>Login screen</Text>

LoginScreen.navigationOptions = ({ navigation }) => ({
  headerLeft: (
    <TouchableOpacity onPress={() => navigation.navigate("Main")}>
      <Text>To Main Tabs</Text>

But i recommend to use the new SwitchNavigator released by react-navigation bump your react-navigation dependency to the latest and use it :sweat_smile: you have an exemple for authentifications flows

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.