I'm trying to implement some api polling code, this is what I've got so far:
async retrieveNotifications() {
const res = await fetch(url)
if (res.status === 200) {
this.props.setNotifications(res.data)
}
setTimeout(() => {
this.retrieveNotifications()
// polling in 10 min cycles
}, 600000);
}
the code works, however the question is if this has any performance downsides because its recursive? Does anyone know a better solution for polling in rn ? Thanks for the help :)