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

121
Views
el temporizador no se ejecutará en segundo plano en JS

Hice un temporizador en reaccionar JS, pero mi único problema es que cuando cambio de pestaña, el temporizador no se ejecuta en segundo plano. ¿Cómo puedo solucionar esto?

Aquí está el código ->

 const [time, setTime] = useState({ms:0, s:0, m:0, h:0}); const [interv, setInterv] = useState(); const [status, setStatus] = useState(0); // Not started = 0 // started = 1 // stopped = 2 const start = () => { run(); setStatus(1); setInterv(setInterval(run, 10)); }; var updatedMs = time.ms, updatedS = time.s, updatedM = time.m, updatedH = time.h; const run = () => { if(updatedM === 60){ updatedH++; updatedM = 0; } if(updatedS === 60){ updatedM++; updatedS = 0; } if(updatedMs === 100){ updatedS++; updatedMs = 0; } updatedMs++; return setTime({ms:updatedMs, s:updatedS, m:updatedM, h:updatedH}); }; const stop = () => { clearInterval(interv); setStatus(2); };
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!