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

293
Views
REACT Js, prevState not saving the previous state in an object

I'm having a problem that I can't solve. I have an empty object saved in a useState, which I have to fill dynamically according to some filters to do a search in an API. When I choose a filter it has no problems, it saves it for me. But when I choose a second filter, it deletes the previous one and saves the new filter. I am using: https://ant.design/components/table/

useState

const [savedFilters, setSavedFilters] = useState({})

onValuesChange

 <Form
            form={form}
            onValuesChange={e => setSavedFilters(
                prevState => ({...prevState, e })
            )}
>

If anyone could help me I would appreciate it!

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

0

did you try to spread 'e' ?

   onValuesChange={e => setSavedFilters(
                prevState => ({...prevState, ...e })
            )}

I would be nice if you told us what value is in savedFilters after update

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!