DEV Community

Discussion on: How to Create a Simple React Countdown Timer

Collapse
 
trangcongthanh profile image
Thành Trang • Edited

Whats limitation?

If your component will unmount, you should lift your count state up (or make it global) to store the current count. Then when remount, init your count state with the previous count. It'll start counting at the previous position.

If you component will not unmount, just clear your current timeout when the tab lost focus. It'll pause. When it get focused again, set your timeout back.