Skip to content

Instantly share code, notes, and snippets.

@AlienDev66
Created November 28, 2020 11:17
Show Gist options
  • Save AlienDev66/59e7ecdc5a036ba72536015384f4dcad to your computer and use it in GitHub Desktop.
Save AlienDev66/59e7ecdc5a036ba72536015384f4dcad to your computer and use it in GitHub Desktop.
Setting a timer for a long period of time, i.e. multiple minutes, is a performance and correctness issue on Android as it keeps the timer module awake, and timers can only be called when the app is in the foreground. See https://github.com/facebook/react-native/issues/12981 for more info.
I also had this bug, I was investigating, and then I came up with the solution that using expo will not solve, however, it can be hidden.
Write this code snippet in the scope of your component, after the imports:
LogBox.ignoreLogs(["Setting a timer"]);
const _console = _.clone(console);
console.warn = (message: string) => {
if (message.indexOf("Setting a timer") <= -1) {
_console.warn(message);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment