const [query, setQuery] = useState([])
React.useEffect (() => {
fetch(url)
.then((res) => res.json())
.then((data) => {
setQuery(data)
console.log(query);
handleChange();
})
})
I have 2 issues:
- when I console.log(query), it is empty.but console.log(data) shows the correct array, how?
- handlechange() is getting executed before the fetch is complete, why?
Thank you!