react native use route params
navigation.navigate('RouteName', { /* params go here */ })
to recieve the params
function DetailsScreen({ route, navigation }) {
const { itemId, otherParam } = route.params;
return(<Text>itemId<Text>);
}
react native use route params
navigation.navigate('RouteName', { /* params go here */ })
to recieve the params
function DetailsScreen({ route, navigation }) {
const { itemId, otherParam } = route.params;
return(<Text>itemId<Text>);
}
react native getting old navigation parameter
The problem here is how navigation.navigate works. If you use it without
passing the key for the next screen, react-navigation won't match it with the
screen that is already mounted hence mounting another one.
What you can observe here is exactly the case when the component was not yet
unmounted but navigate doesn't know that and renders another instance of the
same component.
You can prevent this by passing the key param into navigate function as follows:
navigation.navigate({name: 'ScreenB', key: 'ScreenB', params: { id: 1}})
navigation.navigate({name: 'ScreenB', key: 'ScreenB', params: { id: 2}})
Now StackNavigator can check if screen with the same key already exists and
prevent it from mounting.
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us