AppState is your friend! See the AppState documentation .
So, in your component where setTimeout exists, you just need an AppState and add an event listener as follows:
AppState.addEventListener('background', this.handlePutAppToBackground); AppState.addEventListener('inactive', this.handlePutAppToBackground);
handlePutAppToBackground () will now be a method in your component where you would call clearTimeout (...)
itinance
source share