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,078
  • 7
  • 55
  • 112
R. Kohlisch
  • 2,381
  • 6
  • 22
  • 49

1 Answers1

1

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);
  }
G.aziz
  • 3,365
  • 1
  • 13
  • 30