I did see multiple questions related to mine but I couldn't find a proper answer. This is my code but the function inside setInterval is not working. makeAPICall() is not called and the log also didn't execute. Any answer is appreciated.
P.s. I am a newbie so please ignore any mistakes
Code
fetchData() {
reactotron.log('called!!');
if (this.props.isConnected) {
clearInterval(bgTimer);
bgTimer = setInterval(() => {
reactotron.log('inside setTimer callback');
this.makeAPICall();
}, 20000);
}
}
bgTimer is declared above class definition
let bgTimer;
class MyScreen extends Component {