Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

193
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda