Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

318
Views
Uncaught TypeError: Cannot read properties of undefined (reading 'navigate')

I am new to react native and react navigation and I get this error.

Uncaught TypeError: Cannot read properties of undefined (reading 'navigate')

I don't understand my because I am just using the same code which already worked, but now it's not working.

I am trying to make a back arrow that send you back to the MachineList screen.

//doesn't work
const AddMachineDetails = ({route}, props) => {

...

<TouchableOpacity onPress={() => props.navigation.navigate("MachinesList")}>
        <BackArrow />
 </TouchableOpacity>

So when I press my backarrow it send me this error:

Uncaught TypeError: Cannot read properties of undefined (reading 'navigate')

Here is my Navigation file:

import MachinesList from '../components/MachinesList'
import AddMachineDetails from '../components/AddMachineDetails';

...

function MachineListStackScreen() {
    return(
        <Stack.Navigator screenOptions={{headerShown: false}}>
            <Stack.Screen name='MachinesList' component={MachinesList}/>
            <Stack.Screen name='AddMachineDetails' component={AddMachineDetails}/>
        </Stack.Navigator>
    )
}

...

I think the problem is somewhere in this code, but if not, I'll show you more of my code

Here is an example where my navigation.navigate work perfectly:

//no specific imports  (but works)

const MachinesList = (props) => {

...


<TouchableOpacity style={styles.machineBox} onPress={() => props.navigation.navigate('AddMachineDetails', {item})}>
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You have to desctruct the props argument.

const AddMachineDetails = ({route, ...props}) => { ... }  

or

const AddMachineDetails = ({route, navigation, ...props}) => { ... }  // then straightly use the *navigation*
about 4 years ago · Juan Pablo Isaza Report

0

The issue is here ({route}, props) =>.

You are destructuring the first argument, but there aren't other parameters passed and that's why "props" variable is undefined.

You have two solutions:

  1. Just use props:
const AddMachineDetails = (props) => {
  1. Destructure props:
const AddMachineDetails = ({route, navigation, ...props}) => {
...

<TouchableOpacity onPress={() => navigation.navigate("MachinesListDetails")}>
       <BackArrow />
</TouchableOpacity>
about 4 years ago · Juan Pablo Isaza Report

0

Optional chaining can be useful in future to prevent errors in runtime. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!