Rambler
Rambler

Reputation: 277

Navigation changed in react native

I have changed from the this navigation

"react-navigation": "^4.4.3",

to

"@react-navigation/stack": "^6.0.11",

But the problem is now app is crashing due to

props.navigation?.state?.params?.data

Above route params are working in the whole app so anyone can let me know how can i resolve it. So i got all the params with less changes. As these are changed in both versions.

Thanks

Upvotes: 0

Views: 111

Answers (1)

Gokul Kulkarni
Gokul Kulkarni

Reputation: 2239

Follow the below code,

function DetailsScreen({ route, navigation }) {
    const {itemId} = route.params;
}

--------------OR----------------

using hooks

import {useRoute} from '@react-navigation/core';
function DetailsScreen({ route, navigation }) {
    const route = useRoute();
    const {itemId} = route.params;
}

Upvotes: 1

Related Questions