Closed MaxBittker closed 2 years ago
react renders components twice when it's run in strict mode, to help find accidental side effects, it looks like this hook does not close the old web-socket in that situation. (only effects share: false)
share: false
I think the solution would be returning a cleanup function at the end of this useEffect: https://github.com/robtaussig/react-use-websocket/blob/master/src/lib/use-websocket.ts#L139
See these issues:
https://github.com/facebook/create-react-app/issues/10387
https://github.com/facebook/react/issues/15074#issuecomment-471197572
react renders components twice when it's run in strict mode, to help find accidental side effects, it looks like this hook does not close the old web-socket in that situation. (only effects
share: false
)I think the solution would be returning a cleanup function at the end of this useEffect: https://github.com/robtaussig/react-use-websocket/blob/master/src/lib/use-websocket.ts#L139
See these issues:
https://github.com/facebook/create-react-app/issues/10387
https://github.com/facebook/react/issues/15074#issuecomment-471197572