I want to basically do a backup every X minutes, but let's for simplicity's sake say I want to just console log something or do some async stuff. It should run in the background and not block the rest of my app. Any advice?
Asked
Active
Viewed 786 times
0
-
1`setInterval(() => console.log('hello'), 60000) // once a minute (roughly)` – Heretic Monkey Jul 17 '19 at 21:05
1 Answers
2
you can use setInterval
in componentDidMount
and you can change 1000
to a variable.
componentDidMount() {
this.interval = setInterval(() => console.log("here"), 1000 );
}
componentWillUnmount() {
clearInterval(this.interval);
}

Aziz.G
- 3,599
- 2
- 17
- 35