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

109
Views
¿Cómo puedo escuchar/cambiar mi estado con setIntreval?

Necesito mostrar mi temporizador en el componente de reacción, está funcionando en función, pero no puedo mostrarlo en html porque mi estado funciona muy mal.

 const date = { // timer context hours: 0, minutes: 0, seconds: 0, isActive: false, start: function() { this.isActive = true; return this }, stop: function() { this.isActive = false; return this } } function timer() { //timer function if(this.isActive) { if(this.seconds < 60) date.seconds += 1; else { this.seconds = 0; if(this.minutes < 60) date.minutes += 1; else { this.minutes = 0; this.hours += 1; } } } return this } const myTimer = timer.bind(date); const [timerState, setTimerState] = useState({}); // myState let interval; useEffect(() => { if(interval) clearInterval(interval); interval = setInterval(() => { if(clients.length > 1) { setTimerState(myTimer().start()); // state changed } else { setTimerState(myTimer().stop()); } console.log(timerState); }, 1000); }, [clients, timerState /* waiting update states */]); // but i can't wait only clients otherwise i get empty object {} if remove timerState from wait states

Necesito retirar el estado del temporizador en el retorno del componente html ({timerState})

Dime por favor que necesito. Gracias.

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!