i’m trying to build an app and pass parameter to between pages. so i’m using to navigation. here PageOne code:
const PageOne=({navigation})=>{
...
onPress={_ => { navigation.navigate("PageTwo", { navigation }) }}>
PageTwo codes
const SettingsPage = ({route}) => {
const {navigation} = route.params
my code is working. i mean, i can use the navigation but getting yellow alert.
2
Answers
This happens when you are trying to pass a callback or something that is not serializable as a param when navigating to a new screen.
in this case you don’t don’t need to pass navigation as a param, so replace this:
navigation.navigate("PageTwo", { navigation })
withnavigation.navigate("PageTwo")
and in your SettingsPage, just do the following
or
@RodSar’ answer really helps me, after a long troubleshoot. so i add this one, saving little time for anyone who needs :
you should import
useNavigation
before you can use it, as @Rodstar mentions :I wanna comment @RodSar but have not enough reputation, so i made this one new answer instead.
SECOND METHOD
or you can also destructure them like this
the result will be same.
AND ALSO you can type it with your
properties.route.params
if you’re passing parameters from previous screenas far as what i tried, all working fine as long as you
don’t pass any navigation as params, where-ever it is
no more
non-serializable-values-were-found-in-the-navigation-state
yellow warn. thanks to @RodSar.