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

154
Views
React Native - Undefined is not an object (evaluating 'navigation.navigate')

In my app, the login function sends the phone number inserted by the user, and if the server returns "success" it is supposed to navigate to another screen. Unfortunately the app returns "Undefined is not an object (evaluating 'navigation.navigate')".

The code is the following:

const login = (mobileNumber, navigation) => {
Object.keys(mobileNumber).forEach((key) => {
  console.log(mobileNumber[key]);
});

if (mobileNumber.mobileNumber == null) {
  alert('Please fill Mobile number');
  return;
}

let dataToSend = {mobileNumber: mobileNumber.mobileNumber};
let formBody = [];
for (let key in dataToSend) {
  let encodedKey = encodeURIComponent(key);
  let encodedValue = encodeURIComponent(dataToSend[key]);
  formBody.push(encodedKey + '=' + encodedValue);
}
formBody = formBody.join('&');

fetch('https://mywebsite.com/api/v1/login.php', {
  method: 'POST',
  body: formBody,
  headers: {
    //Header Defination
    'Content-Type':
    'application/x-www-form-urlencoded;charset=UTF-8',
  },
})
  .then((response) => response.json())
  .then((responseJson) => {
    console.log(responseJson);
    // If server response message same as Data Matched
    if (responseJson.status === 'success') {
      alert("Login OK!");
      navigation.navigate('FeedScreen');
    } else {
      console.log('Please check mobile number');
    }
  })
  .catch((error) => {
    //Hide Loader
    console.error(error);
  });
}
about 4 years ago · Juan Pablo Isaza
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!