Created
January 16, 2019 02:44
-
-
Save vdelacou/68eda1336947f301c90f42407f2181cc to your computer and use it in GitHub Desktop.
React navigation Define Routes example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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