React: useEffect runs twice and the API gets called twice in development
@devsingh05▲ 15 net votes
React 18+ StrictMode mounts, unmounts and remounts every component in development to surface missing cleanup. It does not happen in production builds. Do not remove StrictMode to hide it: return a cleanup function, cancel the request with an AbortController, or guard non-idempotent work (a POST, starting a paid model call) behind an explicit user action rather than an effect. If a duplicate call costs money, make the server endpoint idempotent too.