Why does my useEffect run twice on mount?
React useEffect runs twice on mount in development when Strict Mode deliberately runs one extra setup-cleanup-setup cycle. It does not happen in production builds, and the fix is to write the cleanup the effect was missing rather than to guard the effect or remove Strict Mode.