From 3d08613182fc7e3f039cf1adb5cf6f84de22942e Mon Sep 17 00:00:00 2001 From: useonglee Date: Fri, 28 May 2021 10:10:04 +0900 Subject: [PATCH 01/10] Add chat id to chat data type --- src/components/Chat/ChatContainer/index.tsx | 7 ++++--- src/types/types.ts | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/Chat/ChatContainer/index.tsx b/src/components/Chat/ChatContainer/index.tsx index c8de28c..39d79ca 100644 --- a/src/components/Chat/ChatContainer/index.tsx +++ b/src/components/Chat/ChatContainer/index.tsx @@ -47,8 +47,8 @@ const WorkSpaceChat = (): JSX.Element => { // TODO: 메세지를 받으면 재렌더링 한다. useEffect(() => { - socket?.on('sendMessage', ({ text, writer, room, project, createdAt }: ChatDataType) => { - setChatBucket([...chatBucket, { text, writer, room, project, createdAt }]); + socket?.on('sendMessage', ({ id, text, writer, room, project, createdAt }: ChatDataType) => { + setChatBucket([...chatBucket, { id, text, writer, room, project, createdAt }]); }); }, [chatBucket]); @@ -74,6 +74,7 @@ const WorkSpaceChat = (): JSX.Element => { message: chat, }; const newChat: ChatDataType = { + id: null, text: chat, room: room, createdAt: newChatDate.toString(), @@ -110,7 +111,7 @@ const WorkSpaceChat = (): JSX.Element => { return ( - +