Route object reference
Each screen component in your app is provided with the route object as a prop automatically. The prop contains information about the current route.
routekey- Unique key of the screen. Created automatically or added while navigating to this screen.name- Name of the screen. Defined in navigator component hierarchy.path- An optional string containing the path that opened the screen. It exists when the screen was opened via a deep link.params- An optional object containing params defined while navigating, e.g.navigate('Twitter', { user: 'Jane Doe' }).
- Static
- Dynamic
function ProfileScreen({ route }) {
return (
<View>
<Text>This is the profile screen of the app</Text>
<Text>{route.name}</Text>
<Text>{route.path ?? 'No path'}</Text>
<Text>{route.params?.user ?? 'No params'}</Text>
</View>
);
}
function ProfileScreen({ route }) {
return (
<View>
<Text>This is the profile screen of the app</Text>
<Text>{route.name}</Text>
<Text>{route.path ?? 'No path'}</Text>
<Text>{route.params?.user ?? 'No params'}</Text>
</View>
);
}