Skip to content

Commit

Permalink
Fix: useSocket condition
Browse files Browse the repository at this point in the history
  • Loading branch information
2YH02 committed Nov 10, 2023
1 parent a687d02 commit ae71beb
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/hooks/useSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@ const useSocket = (
});

// 변화 감지
if (callback) {
useEffect(() => {
useEffect(() => {
if (callback) {
socket.on("message-to-client", (messageObject) => {
callback(messageObject);
});

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [socket]);
}

}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [socket]);
// 메시지 보내기
const sendMessage = (text: string) => {
socket.emit("message-to-server", text);
Expand Down

0 comments on commit ae71beb

Please sign in to comment.