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

222
Views
¿Cómo empujar a una matriz de valores de mapa y usarla como estado en React?

Tengo el siguiente estado en React:

 const [tasksMap, setTasksMap] = useState(new Map());

con la siguiente creación del mapa:

 tasks.forEach((task) => { const key = `${week.year}-${week.weekNo}`; if (!tasksMap.has(key)) { tasksMap.set(key, []); } tasksMap.get(key).push(task); });

¿Cómo puedo configurar el mapa tasksMap como el estado React?

setTasksMap(tasksMap.set(key, [])); funciona pero tiene una matriz vacía como valor, que no se actualiza cuando ejecuto tasksMap.get(key).push(task); .

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

0

Por favor, intente esto. Aquí usé separate variable para almacenar datos y finalmente establecí esa variable en el state .

 let mapObj = new Map(); tasks.forEach((task) => { const key = `${week.year}-${week.weekNo}`; if (!mapObj.has(key)) { mapObj.set(key, []); } mapObj.get(key).push(task); }); setTasksMap(mapObj);
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!