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

115
Views
Reaccionar problemas de actualización automática de elementos.

Hola, creé un sistema para controlar múltiples calentadores y ubicaciones, usé Node, React, Javscript, Python3, C y Linux. Aunque tengo una pregunta. Cuál es la mejor manera de actualizar la información en la página. Esto es lo que se me ocurrió. Esto está en el frente de reacción.

 const update = () => { setTimeout(async () => { await fetch(`${backend}/mainobject`, { method: 'GET', mode: 'cors', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', } }).then((responce) => { return responce.json(); }).then((responce) => { for (let i = 0; i < responce[2].length; i++) { if (parseInt(responce[2][i].id) === parseInt(unit.controlRoomId)) { if (document.getElementById(index) !== null) { document.getElementById(index).innerText = "Current Temp: " + responce[2][i].currentTemp; } } } }).catch((error) => { console.log(error); }); update(); }, 60000); } update();

Tengo la sensación de que esta no es la mejor manera de hacerlo. Hice todo el proyecto en video, este es el video en el que agregué la función de actualización. https://youtu.be/pgPWgvoMt5g Utilizo useState para almacenar toda la información que la aplicación necesita en un objeto, pero si tru para obtenerlo automáticamente, entonces causa problemas al usar useState, sigue buscando y volviendo a renderizar. ¿Ideas?

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!