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

220
Views
¿Cómo cambiar backgroundColor para Touchable Opacity usando .map() en la función?

Así que estoy creando una aplicación de prueba y el problema es que necesito resaltar el botón de respuesta marcada. Descubrí cómo hacerlo con Refs, pero funciona solo para tres preguntas. ¿Cómo lo cambio para que funcione durante toda la prueba? mapeo a través de respuestas de preguntas

 <TouchableOpacity key={answers.buttonId} onPress={() => { checkIfCorrect(answers.isCorrect); resetColors(answers.buttonId); highlightBlack(answers.buttonId); }} style={{ borderWidth: 1, width: "80%", margin: "5%", }} > <View ref={(el) => (myRefs.current[answers.buttonId] = el)}> <Text style={{ color: "grey", fontSize: 32, textAlign: "center", }} > {answers.answerText} </Text> </View> </TouchableOpacity> ))}``` Array element with question ```{ questionNumber: 3, questionText: "Solve 1 - 5x = 0.", questionImage: "", answers: [ { answerText: "5", isCorrect: true }, { answerText: "-1/5", isCorrect: false }, { answerText: "1/5", isCorrect: true }, { answerText: "4", isCorrect: false }, ], },``` This how i use refs ``` const highlightBlack = (itemId) => { myRefs.current[itemId].setNativeProps({ style: { backgroundColor: "black" }, }); }; const resetColors = (itemId) => { myRefs.current.forEach((ref) => { if (ref !== itemId) { ref.setNativeProps({ style: { backgroundColor: "white" } }); } }); };``` It crashes after the 3rd question
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!