Since React 18, StrictMode in development mounts a component, immediately unmounts it, and mounts it again. Every effect therefore runs setup, cleanup, setup. This does not happen in a production build and it is not a bug to work around; it is a check that your cleanup actually undoes your setup.
The symptoms are duplicated network requests, two WebSocket connections, doubled analytics events, and intervals that tick twice. Confirm by removing StrictMode temporarily: if the duplication disappears, the effect is missing a cleanup. React also double invokes render functions, state updater functions and reducers in development to surface impure code.
The fix is a real cleanup: abort the request with an AbortController, close the socket, clear the timer. For genuinely once per page work such as an analytics beacon, do it outside React or guard it with a module level flag, not by deleting StrictMode.