i need some help with setstate asynchronous.
i have this select
<select id='province' onChange={handleProvince}>
<option>Select Province</option>
{province?.map(province=>(
<option value={province.id}>{province.name}</option>
))}
</select>
and this is the onchange function
function handleProvince(e){
setProvinceID(e.target.value)
axios.get(`http://192.168.18.46/api/regency/${provinceID}`).then((res)=>{
setRegency(res.data.data)
})
}
putting the setProvinceID(e.target.value)
in the same function causes me to change the select element twice for it to pick the value.
how do i anticipate it?
any help would be much appreciated, thanks