Skip to content

Instantly share code, notes, and snippets.

@anghelalexandra
Created May 15, 2018 18:48
Show Gist options
  • Save anghelalexandra/9ca31ba28f0ee341acf5ac20b16e8fbc to your computer and use it in GitHub Desktop.
Save anghelalexandra/9ca31ba28f0ee341acf5ac20b16e8fbc to your computer and use it in GitHub Desktop.
iOS and Android apps with React Native - React Navigation stack example
import React from 'react';
import { StackNavigator, DrawerNavigator } from 'react-navigation';
import Loading from './screens/Loading';
import Login from './screens/Login';
import Home from './screens/Home';
import Posts from './screens/Posts';
import Post from './screens/Post';
import Settings from './screens/Settings';
import SideMenu from './screens/SideMenu';
/**
* Main screens that require authentication.
*/
const Authenticated = StackNavigator(
{
Home: { screen: Home },
Posts: { screen: Posts },
Post: { screen: Post },
Settings: { screen: Settings },
},
);
/**
* Main navigation stack. Handle non-authenticated and authenticated screens.
* It is defined as a DrawerNavigator, so the side menu appears on top of the headers.
* Use custom side menu component to disable only some screens as menu buttons.
*/
const AppNavigation = DrawerNavigator(
{
Loading: { screen: Loading },
Login: { screen: Login },
Authenticated: { screen: Authenticated },
},
{
drawerWidth: 250,
contentComponent: SideMenu,
},
);
export default AppNavigation;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment