Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

187
Vistas
I can add a feedback object to an array of feedbacks using useContext/ useState, but I can't update any of them, how to do it?

I am working on a feedback app. The main page lists all feedbacks. If you klick "New Feedback" (on main page) a form opens and you can add a new feedback - it works, the new feedback will be added to feedbacks and show on the main page.

Now my struggles starts when I want to edit a feedback: (1) I klick on one of the feedbacks on main (2) It opens a form that is filled with the actual feedback properties (3) I edit the properties (4) I klick on "Edit feedback" which should update my feedback-array but it just doesn't work.

The data comes from a json file. The array of feedbacks ("productRequests" in data.json) are shared as "filteredItems/setFilteredItems" through useContext.

As a test I tried to overwrite my 10+ feedbacks-array with an array of 1 feedback, just to see if I can update it, but it turned into an error: "Cannot read properties of undefined (reading 'title') - which is so strange because this property was read perfectly fine when filling the form with the original feedback properties.

I tried splice method as well, got the same error.

I think I miss something very crucial about useContext and useState that is need to solve this. Could you help me out?

In my gist you find: addFeedback.js (works fine), data.js, editFeedback.js (my problem)

My gist

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda