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

305
Views
No se puede agregar la propiedad 0, el objeto no es extensible cuando se intenta insertar objetos construidos en clase en una lista de arreglos - React/NextJs

Este es el código involucrado en esa función, el objetivo es crear filas para representar en una tabla Material Ui.

 class User { constructor(id, name, email, measured, offset, paidAmount, status, home, misc, plane, transport, partner, isCoupon) { this.id = id this.name = name this.email = email this.measured = measured this.offset = offset this.paidAmount = paidAmount this.status = status this.home = home this.misc = misc this.plane = plane this.transport = transport this.partner = partner this.isCoupon = isCoupon } } const mountTableRows = () => { rawData.map((item, index) => { let user = {} user = new User( item["ulid"], item["Name"], item["Email"], item["Emissions"], item["Quantity"], item["Value"], item["Status"], item.Rawresult["home"], item.Rawresult["misc"], item.Rawresult["plane"], item.Rawresult["transport"], item["Partner"], item["isCoupon"] ) usersList.push(user) }) setIsListMounted(true) } useEffect(() => { if (rawData.length > 0 && !isListMounted) { mountTableRows() } }, [rawData])

He estado recibiendo este error:

Error de tiempo de ejecución no controlado TypeError: no se puede agregar la propiedad 0, el objeto no es extensible

Páginas de origen\dashboard\dashboard.js (124:22) @ eval

 > 122 | item["isCoupon"] 123 | ) > > 124 | usersList.push(user) > | ^ 125 | }) 126 | setIsListMounted(true) 127 | }

Pila de llamadas mountTableRows

páginas\dashboard\dashboard.js (107:16) eval páginas\dashboard\dashboard.js (131:12)

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

0

Encontré el problema.

Estaba tratando de ingresar a un estado sin usar la función setState

 usersList.push(user)

Así que leí mi código nuevamente y noté mi estupidez jaja Para solucionar el problema, simplemente reemplacé el código anterior con este a continuación

 setUsersList(current=>[...current, user])
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!