Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

140
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda