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

304
Views
obtener y pasar parámetros en la navegación de reacción

Al presionar un botón, necesito pasar parámetros a otra pantalla donde se obtiene el valor de ese botón, código a continuación;

pantalla: 1

 <TouchableOpacity onPress={() => navigation.navigate("Quiz", { fetch: "history" })} style={styles.button} > <Text style={styles.buttonText}>History</Text> </TouchableOpacity>

pantalla: 2

 const Quiz = ({ navigation, route }) => { const { fetch } = route.params; const getQuiz = async () => { setIsLoading(true); const url = `https://herokuapp.com/q/${fetch}`; const res = await fetch(url); const data = await res.json(); setQuestions(data.results); setOptions(generateOptionsAndShuffle(data.results[0])); setIsLoading(false); };

Pero durante la búsqueda me sale el siguiente error

 [Unhandled promise rejection: TypeError: fetch is not a function. (In 'fetch(url)', 'fetch' is "history")]

He intentado usar el tiempo de espera pero no funciona, ¿hay alguna opción mejor?

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

0

El problema es que fetch es una función nativa en javascript (ver aquí ).

Debe cambiar el nombre del parámetro a otro nombre como quizz .

pantalla: 1

 <TouchableOpacity onPress={() => navigation.navigate("Quiz", { quizz: "history" })} style={styles.button} > <Text style={styles.buttonText}>History</Text> </TouchableOpacity>

pantalla: 2

 const Quiz = ({ navigation, route }) => { const { quizz } = route.params; const getQuiz = async () => { setIsLoading(true); const url = `https://herokuapp.com/q/${quizz}`; const res = await fetch(url); const data = await res.json(); setQuestions(data.results); setOptions(generateOptionsAndShuffle(data.results[0])); setIsLoading(false); };
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!