Closed zehawki closed 1 year ago
Hmm, this:
Components can close/unsubscribe from a WebSocket by passing false as the third parameter. This provides a more explicit solution than the previous method of setting the socketUrl to null. Both methods work and are supported usage.
is not working as expected.
Whether I set shouldConnect to false, or setSocketUrl(null) - the socket does not actually get closed.
So what should I do to manually close the socket?
I would need more details to diagnose what you are experiencing. A basic example of using the third parameter is working in a shared setting (open dev tools and inspect network tab and you can observe when the websocket transitions from pending state to closed): https://stackblitz.com/edit/react-duw2wn?file=index.js
Documentation does not give any details on
shouldConnect
andprotocols
, and how they are supposed to be used.I'm guessing
shouldConnect
is a way to manually disconnect the websocket based on this line, where it seems the "third param" isshouldConnect
:Components can close/unsubscribe from a WebSocket by passing false as the third parameter.
Will be good to have this documented in the Options section.
Some minor feedback: