Skip to content

fix: multiple connections WITHOUT initial null#4

Closed
jake-morales wants to merge 4 commits into
iamgyz:masterfrom
jake-morales:fix-mult-conns-without-null
Closed

fix: multiple connections WITHOUT initial null#4
jake-morales wants to merge 4 commits into
iamgyz:masterfrom
jake-morales:fix-mult-conns-without-null

Conversation

@jake-morales

Copy link
Copy Markdown

Improves on #3 by not initializing socket as null.

  • Instead, I pass to "useState( )" a function that returns the socket object from "io(...args)".
  • Only one socket connection will be made. Since the initial value is a function, it will only be ran once.
  • This simplifies the code by eliminating the need for "setSocket"

@jake-morales jake-morales changed the title Fix multiple connections without initial null fix: multiple connections WITHOUT initial null Apr 3, 2020
@focux

focux commented Apr 3, 2020

Copy link
Copy Markdown

This won't work when doing SSR, it will execute the function in the server and in the client. Creating at least one connection in the server (could be even more) and another one in the client.

@jake-morales jake-morales closed this by deleting the head repository Feb 18, 2026
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