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

144
Views
¿Debo usar bucles for en ReactJS? ¿Alguna otra forma de cambiar varios elementos a la vez cuando cambia una entrada?

Estoy creando un sistema POS con ReactJS. ¿Debo usar un ciclo for para calcular la cantidad total? Hay alguna otra manera de hacer esto?

 let product = testProducts; let subtotalEl = document.getElementsByClassName("Subtotal"); let quantity = document.getElementsByClassName("Quantity"); for (var i = 0; i < product.length; i++) { subtotalEl[i].innerHTML = product[i].UnitPrice * quantity[i].value; }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  1. No está utilizando reaccionar js, su código parece JavaScript.
  2. Sí, puede usar un bucle para agregar, pero en React se recomienda usar el map para las iteraciones.

Por ejemplo:

 const sum = array_object .map((item) => item.quantity) .reduce((prev, curr) => prev + curr, 1);

Como puede ver, map se usó para recorrer la matriz y reduce para agregar los valores.

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!