From 6ba15ae5390c1f343d360ad2050d9ea58531de7a Mon Sep 17 00:00:00 2001 From: sooraj888 <93926869+sooraj888@users.noreply.github.com> Date: Wed, 23 Aug 2023 13:38:22 +0530 Subject: [PATCH] Update SingleChat.js --- frontend/src/components/SingleChat.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/SingleChat.js b/frontend/src/components/SingleChat.js index b64d3a5..170011b 100644 --- a/frontend/src/components/SingleChat.js +++ b/frontend/src/components/SingleChat.js @@ -90,7 +90,10 @@ const SingleChat = ({ fetchAgain, setFetchAgain }) => { config ); socket.emit("new message", data); - setMessages([...messages, data]); + // setMessages([...messages, data]); + setMessages((prevMessage) => { + return [...prevMessage, data]; + }); } catch (error) { toast({ title: "Error Occured!",