I want to create dynamic routes similar to the way you can with react-router using the slash colon as so:
<Route exact path="/user/:_id" component={UserPage} />
How does this work with react native if I want to open a page specif to a link?
const Item = ({ title }) => (
<View style={styles.item}>
<Button
onPress={() => {
alert(`You tapped ${title}`);
}}
title={title}
>
<Text style={styles.title}>{title}</Text>
</Button>
</View>
);
const MainPage = () => (
<SafeAreaView style={styles.container}>
<SectionList
sections={DATA}
keyExtractor={(item, index) => item + index}
renderItem={({ item }) => <Item title={item} />}
renderSectionHeader={({ section: { title } }) => (
<Text style={styles.header}>{title}</Text>
)}
/>
</SafeAreaView>
);
export default MainPage;
function App() {
return (
<NavigationContainer>
<Stack.Navigator initialRouteName="Home">
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="Details" component={DetailsScreen} />
<Stack.Screen name="MainPage" component={MainPage} />
<Stack.Screen name="MediaScreen" component={MediaScreen} />
</Stack.Navigator>
</NavigationContainer>
);
}
export default App;
I want the Item onPress to go to its own page/screen