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

223
Views
Cómo pasar parámetros a una ruta poniéndolos en un objeto

Intento enviar datos a otra página con el parámetro de paso, de la página 1 a la página 2.

este es mi código de la página 1:

 axios({ method: 'post', url: "http://127.0.0.1:8000/api/masuk", data: { username: {username} } }) .then(function (response){ if (response.data.data != null) { // Alert.alert(`Username ${username} tidak terdaftar`); console.log(response.data) setdataPetugas(response.data) navigation.navigate('Home', {test: 'name'}); } else { console.log(response.data) Alert.alert(`Username ${username} tidak terdaftar`); setLoading(false); } }) .catch(function (error){ console.log(error) });

y este es el código de la página 2:

 const Page = ({route, navigation}) => { const {test} = route.params; console.log(test); return ( <SafeAreaView style={{ backgroundColor: 'white', }}> <ScrollView style={{ paddingHorizontal: '5%' }}> <Texts text="Hi, Asep" color="grey" /> <Gap vertical="5%" /> <View style={{ flexDirection: 'row' }}> <View style={{flex:.8,alignItems:'center'}}> <Image source={require('../../../assets/images/user-profile.png')} resizeMode="cover" style={{ width: 60, height: 60, borderRadius: 10 }} /> </View> <View style={{flex:1}}> <text>{JSON.stringify(test)}</text> <Texts text={''} color="grey"/> <Texts text="+62 856 1234 5678" color="grey"/> <Texts text="Collector" color="grey"/> </View> </View> </ScrollView> </SafeAreaView>

cuando ejecuto el código, el error se muestra así: [TypeError: undefined no es un objeto (evaluando 'route.params.test')]

He actualizado react-navigation/native a la última versión, y eso no resuelve el problema.

Gracias a todos por ayudarme..

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Puede utilizar la API setOptions :

Verifique el siguiente ejemplo de los documentos

 React.useLayoutEffect(() => { navigation.setOptions({ title: value === '' ? 'No title' : value, }); }, [navigation, value]);
about 4 years ago · Juan Pablo Isaza Report

0

// send value navigation.navigate('Home', {test: 'name'}); // getValue const id = navigation.getParam('test')
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!