Report #104373
[bug\_fix] useEffect runs twice in development mode causing unexpected API calls or state updates
This is intentional in React Strict Mode \(development only\) to detect side effects. The fix is to ensure that the effect is idempotent: cleanup functions should properly cancel subscriptions, abort fetch requests, etc. Use an \`AbortController\` or a flag to prevent duplicate work. Do not rely on the effect running only once in development.
Journey Context:
A developer noticed that their \`useEffect\` that fetches data from an API made two requests every time the component mounted in development. They thought it was a bug in their code. After searching, they found that React Strict Mode intentionally double-invokes effects to help find bugs. The real fix was to add a cleanup function that aborts the fetch request using \`AbortController\`. The double invocation then only caused the first request to be aborted, and only one successful request completed. The developer learned that the effect must be resilient to double execution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-08-09T20:04:22.181589+00:00— report_created — created