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

90
Views
Global react hook always a step behind when using onChange

This question has been asked a few times but I've got a bit of a different setup and none of the solutions have worked for me. Here is my code:

  const handleFilter = (e) => {
    //setValues({ ...values, error: false, [e.target.name]: e.target.value });
    console.log("we are updating: ", [e.target.name][0])
    console.log("updated with ", e.target.value)
    setGlobalState([e.target.name][0], e.target.value)
    filterAndSort()
  }

Which is being called by <select className="form-control" name="accommodationType" onChange={handleFilter}>

It's always one step behind in terms of state.

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!