I am trying to save an api response using react hooksand pass it to a fucntion drawChart. In this code the update state of the object is not being passed to my function. What would be the proper way of passing the updated state of the object to the function drawChart ?
useEffect(() => {
axios.get(url)
.then(response => {
var obj = JSON.parse(response.data)
setResponseMonthly(obj);
})
.then(response=>{
drawChart(responseMonthly, 'month')
})
.catch(err => console.log(err))
},[]);