Skip to content

Instantly share code, notes, and snippets.

@vdelacou
Created January 16, 2019 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vdelacou/e2e3f48c1f78d56ad6ce470b6362b33c to your computer and use it in GitHub Desktop.
Save vdelacou/e2e3f48c1f78d56ad6ce470b6362b33c to your computer and use it in GitHub Desktop.
React navigation Define Routes example
import { createAppContainer, createStackNavigator } from "react-navigation";
import { DetailScreen } from "../screens/detail_screen";
import { HomeScreen } from "../screens/home_screen";
import { ModalScreen } from "../screens/modal_screen";
export enum ROUTES {
RootMain = "RootMain",
RootModal = "RootModal",
RootDetails = "RootDetails",
ModalMain = "ModalMain",
MainHome = "MainHome",
MainDetails = "MainDetails"
}
// The stack for the modal
const ModalStack = createStackNavigator({
[ROUTES.ModalMain]: {
screen: ModalScreen
}
});
// The stack for the main navigation
const MainStack = createStackNavigator({
[ROUTES.MainHome]: {
screen: HomeScreen
},
[ROUTES.MainDetails]: {
screen: DetailScreen
}
});
// The app root stack, all navigation start from here
const RootStack = createStackNavigator(
{
[ROUTES.RootMain]: {
screen: MainStack
},
[ROUTES.RootModal]: {
screen: ModalStack
}
},
{
mode: "modal",
headerMode: "none"
}
);
const AppContainer = createAppContainer(RootStack);
export default AppContainer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment