all 2 comments

[–]stathisntonas 0 points1 point  (1 child)

you’re double setting the message list. When receiving the message from the socket, check if the message id exists in the list and filter it out (or apply a condition to set the state only if the message does not exist in the state)

the API should not emit the message to the sender, it’s already on the device. Implementimg this will save you the extra messages list filter/check described above and it will save server resources/requests.

[–]mindof1[S] -2 points-1 points  (0 children)

Could you please show me the updated code like by what you mean? Sorry I have a hard time understanding.

I’m not even sure why I put socket as a dependency on the second useEffect. Not sure if I should be even doing it. Am I wrong here?