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

286
Views
Empuje el objeto en la matriz cuando la casilla de verificación esté marcada y elimine el objeto cuando la casilla de verificación no esté marcada en ReactJS

Estoy tratando de implementar una funcionalidad en la que quiero insertar un objeto en una matriz cuando el usuario lo marcó y eliminarlo si el usuario no lo selecciona. Tengo un menú donde estoy recopilando opciones de usuario. He implementado el código pero no ha resuelto mi problema. ¿Podría alguien ayudarme a resolver este problema? Gracias

 const selectSingle = (id, item, index) => { const user = Cookies.get("user") && JSON.parse(Cookies.get("user")); let callScheduleIds = Object.assign([], allCallNotifications); if (callScheduleIds.findIndex((item) => item.order_id === id)) { callScheduleIds.push({ order_id: id, phone_number: item.phone1, sender_id: user.user.id, }); } else { callScheduleIds.splice(callScheduleIds.indexOf(id), 1); } setAllCallNotifications(callScheduleIds); };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puedes hacerlo usando Lodash .

 const selectSingle = (rowIndex, item) => { let callIds = Object.assign([], allCallNotifications) if (_.findIndex(callIds, { id: item.id }) === -1) { callIds.push(item) } else { callIds.splice(_.findIndex(callIds, { id: item.id }), 1) } setAllCallNotifications(callIds) }
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!