im tring to call this hook but im receiving this error
Possible Unhandled Promise Rejection (id: 6):
Error: Invalid hook call. Hooks can only be called inside of the body of a function component.
this is my code:
const handleEvento = async (dayy) => {
useEffect(()=>{
axios.get(`http://192.168.15.11:8085/api/readEventsByDate/${dayy}`)
.then(response =>{
//Ordenar os dados pelo id em ordem crescente
const sortData= response.data.sort((a,b) => a.id - b.id);
setData2(sortData);
console.log(data2)
})
.catch(error => {
console.log(JSON.stringify(error));
});
},[]);
}
onDayPress={day => {
handleEvento(day.dateString)
}}
i really dont know what im missing here if soomeone can helps i would be really glad