Skip to content

Commit 98612e7

Browse files
committed
Fix order of .on() and .connect() in chat example
1 parent a3e9466 commit 98612e7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/content/learn/reusing-logic-with-custom-hooks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,10 +997,10 @@ export function useChatRoom({ serverUrl, roomId, onReceiveMessage }) {
997997
roomId: roomId
998998
};
999999
const connection = createConnection(options);
1000-
connection.connect();
10011000
connection.on('message', (msg) => {
10021001
onMessage(msg);
10031002
});
1003+
connection.connect();
10041004
return () => connection.disconnect();
10051005
}, [roomId, serverUrl]);
10061006
}

0 commit comments

Comments
 (0)