Why does getParam not work?

I am trying to getParams in my detail page:

<Text>{navigation.getParam('name') }</Text>

I get the error: navigation.getParam is not a function is undefined

instead I have to use:

<Text>{this.props.route.params.params.report.name}</Text>

not sure why?!

I’m guessing that you’re using some kind of navigation package? Perhaps react-router? I’ll assume that.

navigation.getParam is not a function is undefined

This is telling you that the navigation object is not defined. If your component is on the navigation stack, it may come in on props. Have you tried this.props.navigation.getParam(‘name’)?

That will work (I think) if that component is on the navigation stack. If not, you’ve have to pass the navigation object to that component or import it.

Keep in mind that the two methods you list are (I assume if your nav package is like mine.) The first one is trying to access params passed in with the navigation action and the second one is trying to access a variable route that is passed to your component - either directly or through an HOC.