Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
How to bypass tab freezing with my React app?

I have a react app which updates data from a database on a 2 second timer:

componentDidMount() {
    this.interval = setInterval(()=> this.getSelPos(), 2000);
  }
  
  componentWillUnmount() {
    clearInterval(this.interval)  
  }
  
  async getSelPos() {
      const response = await axios.get("http://localhost:5000/selector",  { crossdomain: true });
      console.log(response.data);
      this.setState({SelectorPos: parseInt(response.data.selector)});
      this.setState({Pressure: parseInt(response.data.pressure)});
      this.setState({Temperature: parseInt(response.data.temperature)});

This just sends to a node api that gets a value from my database and responds. Currently set to poll every 2 seconds and update the page.

The problem I'm running into is that when I tab out or minimise the browser for a few minutes it'll hang for a few seconds on returning, or it'll crash entirely. I suspect this is due to the browser being smart and freezing the tab when not in use. But I'm stumped as to how to fix this issue?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!