Code
React effect subscribes but never cleans upcode.effect-without-cleanup
This useEffect adds a listener, starts an interval or opens a subscription, but returns no cleanup function. Every re-render or page visit adds another one: memory grows, handlers fire many times, and realtime/database listeners keep running (and billing) after the component is gone.
- In force Rule code.effect-without-cleanup
- 3 clauses
At a glance
| Severity | medium |
|---|---|
| Certainty | Observed — the code as written is the problem |
| Looks at | your source code |
| When it runs | Runs on every scan |
How to fix it
Return a cleanup: `useEffect(() => { const id = setInterval(tick, 1000); return () => clearInterval(id) }, [])`, `return () => window.removeEventListener("resize", onResize)`, `return () => unsubscribe()`.
Check your own app
Run npx scanlyfix scan in your project. Every finding gets an id; after fixing, npx scanlyfix verify <id> proves it is gone.
If it is a false positive in your project, silence that one line with // scanlyfix-ignore-next-line code.effect-without-cleanup -- <why>.
Your code stays
on your machine
Only findings are uploaded, and only to your own dashboard.
ScanlyFix
Security, privacy pages, SEO and AI visibility checked in one scan, with fixes your AI editor can apply.
Home