Created
April 1, 2018 22:39
-
-
Save horacioh/70f31796f05312c9d2080f28a0ef40ad to your computer and use it in GitHub Desktop.
RN Scaffold - Navigators Index.js
This file contains hidden or 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
// MyApp/src/app/navigators/index.js | |
// @flow | |
import * as React from 'react' | |
import { SwitchNavigator } from 'react-navigation' | |
import PrivateRoot from './PrivateRootNavigator' | |
import PublicRoot from './PublicRootNavigator' | |
import { PRIVATE_ROUTE, PUBLIC_ROUTE } from './routes' | |
function createRootNavigator(signedIn: boolean = false): React.ComponentType<any, any> { | |
return SwitchNavigator( | |
{ | |
[PRIVATE_ROUTE]: { | |
screen: PrivateRoot, | |
}, | |
[PUBLIC_ROUTE]: { | |
screen: PublicRoot, | |
} | |
}, | |
{ | |
headerMode: "none", | |
mode: "modal", | |
initialRouteName: signedIn ? PRIVATE_ROUTE : PUBLIC_ROUTE | |
} | |
); | |
} | |
export const createPrivateRootNavigator = () => createRootNavigator(true); | |
export const createPublicRootNavigator = () => createRootNavigator(false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment