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!",