Skip to content

Instantly share code, notes, and snippets.

@robinheinze
Last active April 9, 2021 18:07
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 robinheinze/60ce60bf239acb0865ace67a7f907172 to your computer and use it in GitHub Desktop.
Save robinheinze/60ce60bf239acb0865ace67a7f907172 to your computer and use it in GitHub Desktop.
IgniteTrivia primary navigator
import { createStackNavigator } from "@react-navigation/stack"
import { QuestionScreen } from "../screens"
/**
* This type allows TypeScript to know what routes are defined in this navigator
* as well as what properties (if any) they might take when navigating to them.
*
* If no params are allowed, pass through `undefined`. Generally speaking, we
* recommend using your MobX-State-Tree store(s) to keep application state
* rather than passing state through navigation params.
*
* For more information, see this documentation:
* https://reactnavigation.org/docs/params/
* https://reactnavigation.org/docs/typescript#type-checking-the-navigator
*/
export type PrimaryParamList = {
question: undefined
}
// Documentation: https://reactnavigation.org/docs/stack-navigator/
const Stack = createStackNavigator<PrimaryParamList>()
export function MainNavigator() {
return (
<Stack.Navigator
screenOptions={{
headerShown: false,
}}
>
<Stack.Screen name="question" component={QuestionScreen} />
</Stack.Navigator>
)
}
/**
* A list of routes from which we're allowed to leave the app when
* the user presses the back button on Android.
*
* Anything not on this list will be a standard `back` action in
* react-navigation.
*
* `canExit` is used in ./app/app.tsx in the `useBackButtonHandler` hook.
*/
const exitRoutes = ["question"]
export const canExit = (routeName: string) => exitRoutes.includes(routeName)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment