1

So I have a file called LoginScreen.js that calls the component PhoneLogin.js. From LoginScreen.js I can run this code this.props.navigation.navigate('App') and the app properly navigates, however when I run that code from PhoneLogin.js I get the following error:

TypeError: Cannot read property 'navigate' of undefined

I believe this is because the component PhonLogin doesn't have the props of navigation, but how can I extend the props?

1 Answer 1

2

Yes it's missing the navigation prop. You have to pass it to your component from the parent. For example, if you're using JSX, <PhoneLogin navigation={this.props.navigation} ... />.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks!! That worked flawlessly just without the "...".
Ah, that was just to indicate that you can pass additional props, see reactjs.org/docs/components-and-props.html for more.
Oh, ok! Thank you very much then.
Someone has been systematically going through my profile and downvoting all questions and answers I've provided on Stackoverflow. The admins seem to be content letting it happen as well. Therefore, I would ask that any subsequent visitors of this post please vote genuinely and leave a comment explaining why you did or did not find the post useful. I'm not trying to indulge in some pathetic tit-for-tat, I just want to help the next person. Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.