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

191
Views
¿Cómo puedo cambiar el estilo después de mapear la matriz con js?

Me gustaría cambiar el color a verde del elemento "tr.amount" si es > 0

Probé con el siguiente código, pero me da este error: TypeError no detectado: no se pueden establecer propiedades de indefinido (estableciendo 'color')

¡Gracias por adelantado!

 {userData.transactions.length > 0 && userData.transactions.map((tr) => ( <tr className="border"> <td> <span className="history-category">{tr.category}</span></td> <td className="amount">{tr.amount > 0 ? tr.amount.style.color = "green" : tr.amount.style.color = "red"}</td> <td>{tr.date}</td> </tr> ))}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Probablemente quiera usar la propiedad de style del propio td . Algo en líneas de

 <td className="amount" style={{ color: tr.amount > 0 ? "green" : "red" }}> My Content </td>
about 4 years ago · Juan Pablo Isaza Report

0

Tienes tr.amount.style.color en lugar de tr.style.color .

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!