Code
Effect with no dependency list makes a request on every rendercode.effect-refetch-every-render
This useEffect has no dependency array, so React runs it after EVERY render, and it makes a network or database request each time. When it also saves the response in state, the new state causes a render, which runs the effect again: an endless loop of requests that freezes the page, burns through your Supabase/Firebase/API quota and can run up a bill while the tab is open.
- In force Rule code.effect-refetch-every-render
- 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
Pass a dependency array as the second argument: `[]` to fetch once when the component mounts, or the values the request depends on (`[userId]`). Better still, use a data-fetching library (TanStack Query, SWR) or fetch on the server.
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-refetch-every-render -- <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