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

93
Views
Operador de propagación para actualizar la matriz de objetos

Tengo una variedad de objetos. En esa matriz, quiero actualizar un solo objeto, y en ese objeto, quiero actualizar solo propiedades específicas. Lo intenté:

 setRequiredFields(prevRequiredFields => ([ ...prevRequiredFields, prevRequiredFields.find(x => x.name = field) ? { isValid: isValid, content: content, isUnchanged: false } ]));

Pero no funcionó. Los campos requeridos son una matriz con la siguiente estructura:

 [{ name: "Name", isValid: false, content: "", isUnchanged: true, tip: "Name cannot be empty", isValidCondition: notEmptyRegex, reportState: validateField }]

Lo que estoy tratando de hacer aquí es actualizar solo isValid , content y isUnchanged de un objeto específico dentro de esa matriz. ¿Cómo puedo lograr eso?

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

0

Si tiene una matriz de objetos y desea actualizar algunas propiedades de uno de los objetos dentro de la matriz.

const index = state.findIndex(x => <h1>HOLA MUNDO</h1>); 
const newState = [....state];
for(let i = 0; i< state.legth;i++){
if(index > -1) { 
 newState[i] = { ...newState[index], isValid:true}
}}
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!