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.