function Chat() {
useEffect(() => {
console.log('connect');
return () => console.log('disconnect');
}, []);
return <h1>Chat</h1>;
}
connect, disconnect, connectIt logs connect, disconnect, connect. In development, StrictMode runs an extra setup and cleanup cycle on mount. This reveals missing cleanup. So you see setup, cleanup, setup. A single connect is what production logs.
"connect, connect" is the tempting wrong answer. The cleanup always runs between the two setups, so two connect lines in a row never happen.