Created
April 5, 2024 14:39
-
-
Save waquwex/de7f823ea953f75d1e81ddd52de36fa2 to your computer and use it in GitHub Desktop.
React Native Navigation
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
| import { NavigationContainer } from "@react-navigation/native"; | |
| import GibberishScreen from "./screens/GibberishScreen"; | |
| import HomeScreen from "./screens/HomeScreen"; | |
| import { createNativeStackNavigator } from "@react-navigation/native-stack"; | |
| export type AppStackParamList = { | |
| Home: undefined; | |
| Gibberish: { example: string }; | |
| } | |
| const Stack = createNativeStackNavigator<AppStackParamList>(); | |
| export default function App() { | |
| return ( | |
| <NavigationContainer> | |
| <Stack.Navigator initialRouteName="Home" screenOptions={{ headerShown: false }}> | |
| <Stack.Screen name="Home" component={HomeScreen} /> | |
| <Stack.Screen name="Gibberish" component={GibberishScreen} /> | |
| </Stack.Navigator> | |
| </NavigationContainer> | |
| ) | |
| } |
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
| type Props = NativeStackScreenProps<AppStackParamList, "Gibberish">; | |
| function GibberishScreen(props: Props) { | |
| //... | |
| return ( | |
| <Text>{props.route.params.example}</Text> | |
| ) | |
| } |
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
| type Props = NativeStackScreenProps<AppStackParamList, "Home">; | |
| function HomeScreen(props: Props) { | |
| //... | |
| const navigateToAnotherScreen = (event: GestureResponderEvent) => { | |
| props.navigation.navigate("Gibberish", { example: "PARAM EXAMPLE" }); | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment