How to include Drawer Navigator inside Stack Navigator inside Tab Navigator with a single navigation file

Nicolas Silva

First of all, yes i'm aware there are many answers related with this question, but i found this specific way to make my navigation in react-native 0.60, the thing is, i haven't figure it out yet, and i don't want to scrape this navigation method to test a different one, this is the navigation file, not sure how to put the drawer inside where or how.

const HomeStack = createStackNavigator(
  {
    Home: HomeScreen
  },
  {
    defaultNavigationOptions: {
      header: null
    }
  }
);

const VacationsStack = createStackNavigator(
  {
    Vacations: VacationsScreen,
    Request: RequestScreen
  },
  {
    defaultNavigationOptions: {
      headerStyle: {
        backgroundColor: "#0091EA",
      },
      headerTintColor: "#FFF",
      title: "Vacaciones"
    }
  }
);

const HourAllocationsStack = createStackNavigator(
  {
    HourAllocations: HourAllocationsScreen,
    Allocations: AllocationsScreen
  },
  {
    defaultNavigationOptions: {
      headerStyle: {
        backgroundColor: "#0091EA"
      },
      headerTintColor: "#FFF",
      title: "Registro"
    }
  }
);

const ExpensesStack = createStackNavigator(
  {
    Expenses: ExpensesScreen
  },
  {
    defaultNavigationOptions: {
      headerStyle: {
        backgroundColor: "#0091EA"
      },
      headerTintColor: "#FFF",
      title: "Rendir"
    }
  }
);

const CertificatesStack = createStackNavigator(
  {
    Certificates: CertificatesScreen
  },
  {
    defaultNavigationOptions: {
      headerStyle: {
        backgroundColor: "#0091EA"
      },
      headerTintColor: "#FFF",
      title: "Certificados"
    }
  }
);

const MainApp = createBottomTabNavigator(
  {
    Home: HomeStack,
    Vacations: VacationsStack,
    HourAllocations: HourAllocationsStack,
    Expenses: ExpensesStack,
    Certificates: CertificatesStack
  },
  {
    defaultNavigationOptions: ({ navigation }) => ({
      tabBarIcon: () => {
        const { routeName } = navigation.state;
        if (routeName === "Home") {
          return (
            <Icon name="home" size={ 25 } color="gray"/>
          );
        }
        if (routeName === "Vacations") {
          return (
            <Icon5 name="sun" solid size={ 25 } color="gray"/>
          );
        }
        if (routeName === "Expenses") {
          return (
            <Icon5 name="plane" size={ 25 } color="gray"/>
          );
        }
        if (routeName === "Certificates") {
          return(
            <Icon name="bill" size={ 25 } color="gray"/>
          );
        }
        if (routeName === "HourAllocations") {
          return(
            <Icon name="clock" solid size={ 25 } color="gray"/>
          );
        }
      }
    }),
    tabBarOptions: {
      activeTintColor: "#FF6F00",
      inactiveTintColor: "#263238"
    },
  }
);

const DrawerNavigation = createDrawerNavigator({
  User: UserScreen,
  Settings: SettingsScreen
})

export default createAppContainer(MainApp);
hong developer

Put the tab navigator in the drawer Navigator, and put the drawer Navigator in the stack navigator.

const DrawerNavigation = createDrawerNavigator({
  User: UserScreen,
  Settings: SettingsScreen,
  MainTab : MainApp
},
{
 initialRouteName : 'MainTab'
})

...
const MainStack = createStackNavigator(
  {
    MainScreen: DrawerNavigation
  },
  {
   initialRouteName : 'MainScreen' 
  }
);

export default createAppContainer(MainStack);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to go back by backButton in stack navigator that is inside drawer navigator

Drawer Navigate inside a stack Navigator

React Navigation (V2): How to set the Icon and the label of a stack Navigator inside a Drawer Navigator?

How to nest Stack Navigator inside a Drawer Navigator with navigation v5+

Add a stack navigator inside a tab navigator

How to add bottom tab navigator to one screen inside stack navigation?

How to use react native navigation to create a nested navigation? (Example: Stack navigator inside a Tab navigator)

How to set always first screen of Stack Navigator inside Tab Navigator React Navigation 5

How to go to initialRoute with react-navigation when exiting a child stack navigator inside a drawer?

How can i add a navigation drawer inside a stack navigator in an already existing project

react navigation tab navigator inside static layout

How to get the current route name of a Stack Navigator that is inside a Bottom Tab Navigator?

Nested tab navigators don't work inside drawer navigator

React-native - tab navigator nested inside drawer

React navigation 5 stack navigator and drawer navigator together

React Navigator 5; Tab Navigator and Stack Navigator

Are you able to programmatically generate screens inside React Navigation Tab Navigator

How to use Drawer Navigator & Stack Navigator combined in react-native?

How to reset the stack navigator and then navigate to a Tab in Tab navigator?

React Navigation: nesting stack and tab navigator

using drawer navigator and stack navigator in react native

How to implement drawer navigator in each tab?

How to pass params from a stack navigator to a Material top tab navigator?

how to pass properties to a react-native component inside a tab navigator?

How to render a button inside screenOptions on Stack.Navigator?

update `headerRight` inside a screen that is hosted by stack navigator

Navigate from a Bottom Tab Navigator to a Stack Navigator

React Native tab navigator nested in stack navigator

Navigate to Tab Navigator from Stack Navigator with Params

TOP Ranking

HotTag

Archive