logo

Cleaning up setInterval with Vue's onMounted and onUnmounted

Tying the timer's lifecycle to the component

Joel Clermont
Joel Clermont
2026-05-15

In the previous video, I showed how Vite's HMR can leave two setInterval timers running in a Vue component when you save a change.

In today's video, I walk through the cleanup fix that ties the timer's lifecycle to the component itself, which handles HMR and normal unmounting alike.

Watch Now (3 min)

And after watching, don't forget to subscribe to our YouTube channel, so you don't miss future videos.

Here to help,

Joel

P.S. Wrangling a head-scratcher in your Laravel project? Schedule a call with us.

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼
email
No spam. Only real-world advice.