DEV Community

Discussion on: Private chat using Socket.io

Collapse
 
isaacpro01 profile image
ssemugenyi isaac

Thanks Jiayi for this awesome article, I am experiencing a challenge in my react native app, hope you can help out, in the event that I listen for an 'onMessage', which kind of state or condition do I need to pass down to my useEffect inorder for it to update the recvMessages state when a new message is sent.
useEffect(()=>{
// receive message
socket.on('onMessage', message => {
setRecvMessages(prevState => GiftedChat.append(prevState, message));
});
}, [ ]);

As of now i can receive these messages on the other users ends

Collapse
 
isaacpro01 profile image
ssemugenyi isaac

Sorry, I meant the other user can receive messages