Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda