Here's a snippet if my code. When I call filteredData(), the state is not updated. I have to click the button twice before the state updates. This is an old project that I am updating using hooks. I previously used a callback function after setting the state, but I can't do that with hooks.
function change(event) {
let name = event.target.name;
let value =
event.target.type === "checkbox"
? event.target.checked
: event.target.value;
setState((prevState) => ({ ...prevState, [name]: value }));
filteredData()
}