robtaussig / react-use-websocket

React Hook for WebSocket communication
MIT License
1.63k stars 135 forks source link

If the hook handles component unmount for us, do we need to do anything? #147

Closed vedantroy closed 2 years ago

vedantroy commented 2 years ago

First, thanks for making this library!

Now, a quick question. The docs have the following example:

  {
    shouldReconnect: (closeEvent) => {
      /*
      useWebSocket will handle unmounting for you, but this is an example of a 
      case in which you would not want it to automatically reconnect
    */
      return didUnmount.current === false;
    },

I'm having trouble understanding this, does this mean I should not need to implement this code in my actual application (e.g, it's just code for the sake of code in the demo), or should I implement this code in my actual application?

robtaussig commented 2 years ago

@vedantroy no need for you to implement!