Skip to content

Sometime emit() is not working #4686

Discussion options

You must be logged in to vote

I got the solution.

I will be happy to share what the issue was.

t was a socket connection issue

  1. I'm using useEffect to connecting my socket when anyone enters this page.
  2. When any user enters this page socket.connect() is triggered.
  3. But when I tried to send a message, that time socket doesn't know what I do?
  4. Like socket.emit() used or not?
  5. What do you thank is the solution for this issue???

The solution is I think that remember (I'm not sure it's a really a solution or not)

const sendMessage = (e: FormEvent) => {
    e.preventDefault();
    socket.connect();
    socket.emit("message", message);
    setMessage("");
  };

When I am trying to send message after that I just reconnect my so…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by devlopersabbir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant