0

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?

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
R. Kohlisch
  • 2,823
  • 6
  • 29
  • 59

1 Answers1

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