Skip to content

Conversation

@carlospatinos
Copy link
Owner

@doncesarts I found the issue with the disconnections, it seems it is down to the client actually disconnecting/connecting by creating a new ClientSocketEvents every time the useEffect inside the useSocket is used. I think useEffect gets called every time reacts render things right? and if that creates a ClientSocketEvent which in times does this:
const socket = io(ioUri);
I think thats the reason we are getting disconnections, connections.

const socketEventsRef = ClientSocketEvents();

Now i wonder whats the best way to avoid that in the react world. Not that familiar with customHooks or useEffect. I was trying to move the creation outside that but does not seem to work. Any ideas are welcome

DONT merge it pls. This is just to show you the issue

@carlospatinos carlospatinos requested a review from doncesarts June 4, 2021 22:07
@carlospatinos carlospatinos marked this pull request as draft June 9, 2021 12:39
@carlospatinos carlospatinos removed the request for review from doncesarts June 9, 2021 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants