Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda