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

104
Views
Agregar nuevos elementos al modelo de objeto existente reaccionar js

júnior tratando de aprender. Tengo la siguiente función.

 overlay = (rulersOnLine) => { const mainRulers = { AB: <Box sx={SX.ruler10} />, CD: <Box sx={SX.ruler20} />, }; let skeleton; let newRulersOnLine = []; rulersOnLine.map((value, index) => { if (value === 1) { skeleton = { name: 'A' + index + 'B' + index, node: <Box sx={SX.ruler10} style={{opacity: 1}} />, }; } }); return mainRulers; };

Mi objeto principal es

 const mainRulers = { AB: <Box sx={SX.ruler10} />, CD: <Box sx={SX.ruler20} />, };

Quiero agregar más elementos dinámicos , por ejemplo:

A1B1: <Box sx={SX.ruler20} />

rulesOnLine es una matriz hecha de 0,1 (máximo 4 elem).

¿Cómo puedo agregar nuevos elementos (bajo el formulario dado) al objeto principal?

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

0

Si entiendo correctamente que desea agregarlo a mainRulers , puede hacer lo mismo

 overlay = (rulersOnLine) => { const mainRulers = { AB: <Box sx={SX.ruler10} />, CD: <Box sx={SX.ruler20} />, }; rulersOnLine.forEach((value, index) => { if (value === 1) { mainRulers[`A${index}B${index}`] = ( <Box sx={SX.ruler10} style={{ opacity: 1 }} /> ); } }); return mainRulers; };
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!