I want to display the messages from the receiver , when i checked with the console.log(receiveMessages) i'm getting the data as displayed in the below image. But i want data to be set as ["hello", "hello amii"] in a single array , please help me thanks in advance
const [receiveMessages, setReceiveMessages] = React.useState([]);
socket.on('receive_message', (chatId,msg) =>{
let newStateMsg = ([...receiveMessages, msg]);
setReceiveMessages(newStateMsg);
})
useEffect(() => {
console.log(receiveMessages)
}, [receiveMessages]);
