You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to integrate Socket IO (v3.1.1) with my react app. I am able to make a connection between the client and server. I have a button event handler that does the following:
So when I press the button, I see "Button pressed" on my server's console, and "Roger that!" on my client's console. However the msg state variable is not updated. What is going? How can I get the state variable to be updated in response to emitted messages?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am trying to integrate Socket IO (v3.1.1) with my react app. I am able to make a connection between the client and server. I have a button event handler that does the following:
The server has the following code:
Back on the client side, after confirming that the socket connection is created, I have the following code:
So when I press the button, I see "Button pressed" on my server's console, and "Roger that!" on my client's console. However the
msg
state variable is not updated. What is going? How can I get the state variable to be updated in response to emitted messages?Beta Was this translation helpful? Give feedback.
All reactions