React Pomodoro Clock: problem clearing SetInterval

Everything works fine, but the setInterval won´t stop after reaching zero, and will keep counting down. What am I doing wrong? Does it have something to do with “this.Interval”?

this.Interval does not seem to be properly defined :thinking:.

Why do not you include among your state variables?

Another suggestion: define the function that decrements the counter as a method and stores the process ID in a state variable.

Thank you, but the Interval does work properly. It just never stops when reaching zero.

Then the method clearInterval() is not working. Therefore, it is better that you store the process ID as a state.

Try console.log(this.Interval) just before clearInterval()

Nothing gets logged.

Then the interval exists in first instance but this is not saved. This must be store (react state) to stop with clearInterval()

Sorry, I don´t really understand what you´re saying.

What console.log(this.Interval) returns? undefined?

No. Nothing shows up on the console.

The method clearInterval() requires a process ID of setInterval(). If the ID process is not saved, the interval can not get stopped.

I don´t think that´s it, to be honest, since this.Interval correctly links the Interval to the variable.

:thinking: If this.Interval link the interval to the variable, then why console.log(this.Interval) do not works?

I did a console log on Timer. It seems that, while the time on screen does count down and gets displayed correctly, the timer on state never actually changes (it always logs the same).
Any ideas why?

For anyone who cares: the problem was that I was checking for the conditions inside the handler and not inside SetInterval.

ฉันเข้าสู่ระบบคอนโซลจับเวลา ดูเหมือนว่าในขณะที่เวลาบนหน้าจอจะนับถอยหลังและได้รับการแสดงอย่างถูกต้องตัวจับเวลากับสถานะจะไม่เปลี่ยนแปลงไปตลอดเวลา
ความคิดใดทำไม? UFABET