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

186
Views
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
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!