Route parameters
When you develop React web applications, some of your routes have dynamic data in them. For example, you can link to a details page, and within that URL, you’ll have some sort of identifier. The component then has what it needs to render specific detailed information. The same concept exists within react-navigation
. Instead of just specifying the name of the screen that you want to navigate to, you can pass along additional data.
Let’s take a look at route parameters in action.
We’ll start with the App
component:
const Stack = createNativeStackNavigator<RootStackParamList>();
export default function App() {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Home" component={Home} />
<Stack.Screen name="Details" component={Details} />
</Stack.Navigator>
</NavigationContainer>
);
}
This looks just like the example...