Pass and get parameters in react navigation 5

346 views Asked by At

how can I pass and get parameters in react navigation? I have tried

 this.props.navigation.getParams('name',defaultValue)

to get the parameter.

1

There are 1 answers

0
Zahra Mirali On BEST ANSWER

get param:

const name = props.route.params.name

pass params:

navigation.navigate({
  name: 'RouteName',
  params: {
      name: 'nameParam'
  }
})

or:

navigation.navigate('RouteName', {name: 'nameParam'})