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

705
Vistas
TypeError: undefined is not an object (evaluating 'route.params.myText')
function Screen2({route, navigation}) {
  
    
    return (
      <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
        <Text>{route.params.myText}</Text>
      </View>
    );
  }

export default Screen2;

Here myText is a string that is passed from other screen(login Screen).

login Screen---------------------------------------

<View>
                <Button style={styles.loginBTN} title="Login"
                onPress={() => {navigation.navigate('Screen2'), {myText: "hello react-native"}}} />
            </View>
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I guess there's a situation (maybe before unmounting) that route or route.params is undefined,

you can solve it this way

function Screen2({route, navigation}) {  
    return (
      <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>

        //I added question mark before the dots (optional chaining)
        <Text>{route?.params?.myText}</Text>
      </View>
    );
  }
export default Screen2;

it's called optional chaining, according to Mozilla

It enables you to read the value of a property located deep within a chain of connected objects without having to check that each reference in the chain is valid.

about 4 years ago · Juan Pablo Isaza Denunciar

0

your login button press should pass the params like below

onPress={() = navigation.navigate("Screen2", {
          myText: "hello react-native",
        })
}
about 4 years ago · Juan Pablo Isaza Denunciar
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