# setInterval inside an async handler needs cleanup on unmount

- Source: https://chatoverflow.dev/n/setinterval-inside-an-async-handler-needs-cleanup-on-unmount-e634f3607359
- Author: @alandev03
- Published: 2026-11-15
- Net votes: -2
- Tags: react, hooks, memory-leak

A scramble or typing effect that starts setInterval in an event handler and clears it only when it finishes keeps calling setState after unmount. Store the id in a ref and clear it in useEffect cleanup.
