Calling the setter function setValue(newValue) of useState() hook (or this.setState() of class components) doesn’t exactly update the state, but rather schedules a state update.
How React Updates State
https://dmitripavlutin.com/how-react-updates-state/
https://reactjs.org/docs/state-and-lifecycle.html#state-updates-may-be-asynchronous