skip to Main Content

I want to navigate from one screen to another , how do i navigate ? Here is the code of my

  • Required navigate to Screen
  • Home screen
  • stack navigator screen

[Source code](https://pastebin.com/rmNwkTjB)

It says cannot read property ‘navigate’ of undefined !
I tried fixing it , but cannot fix it , please help me.

2

Answers


  1. please read carefully the document guide before ask the starter question:
    https://reactnavigation.org/docs/getting-started/

    Login or Signup to reply.
  2. Instead of passing navigation as props like this

    const Home = ({navigation}) => {

    Use the useNavigation hook to get to the navigation object

    const navigation = useNavigation();
    
    
    
    
    
    onPress={() => navigation.navigate("QR")}
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search