My problem is, I want to do an async function, that executes when the user accesses a "page" it executes, gathers data from the database, and show it to the user, it works but into a never-ending loop. Here's the code:
const [subbbed, setSubbed] = useState([])
async function showSubscribed() {
const response = await api.get('subscribed', {
params: {
hour_id: person.id
}
})
return response.data
}
useEffect(()=>{
showSubscribed().then((data)=>{
setSubbed(data)
})
})
And that "setSubbed(data)" is the one that generates the loop.