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

225
Views
Forma de gancho de reacción useFieldArray: en mis códigos, ¿es posible reducir la matriz o no?

Tengo estos datos cuando consola.log (datos):

 export const data = [ { test: [ { product: "Shirt1", variantion: [ { size: "M", color: "blue" }, { size: "S", color: "blue" } ] }, { product: "Shirt3", variantion: [ { size: "L", color: "red" }, { size: "M", color: "blue" } ] } ] } ];

En lugar de tener la prueba, ¿se puede convertir a algo como esto? ¿O causará algún problema en el futuro ya que se trata de una matriz anidada?

 export const data = [ { product: "Shirt1", variantion: [ { size: "M", color: "blue" }, { size: "S", color: "blue" } ] }, { product: "Shirt3", variantion: [ { size: "L", color: "red" }, { size: "M", color: "blue" } ] } ];

enlace de codesandbox: https://codesandbox.io/s/react-hook-form-usefieldarray-nested-arrays-2-efwq6

Intenté eliminar la test

 const defaultValues = { test: [ { product: "", nestedArray: [{ size: "", color: "", design: "" }] } ] };

Pero tendrá estos errores:

 /src/index.js: Unexpected token (11:4) 9 | const defaultValues = { 10 | > 11 | { | ^ 12 | product: "", 13 | nestedArray: [{ size: "", color: "", design: "" }] 14 | } browser Parsing error: Unexpected token 9 | const defaultValues = { 10 | > 11 | { | ^ 12 | product: "", 13 | nestedArray: [{ size: "", color: "", design: "" }] 14 | } (null)
about 4 years ago · Juan Pablo Isaza
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!