react-use-websocket
react-use-websocket copied to clipboard
Rationale for using flushSync?
Noticed that internals of this hook use flushSync to force updates, but is there a strong reason for this as opposed to other approaches?
FlushSync use is generally discouraged and dubbed a last resort by the React documentation. It is also known to crash the entire app in certain circumstances due to React internals throwing.
I would be happy to provide a PR getting rid of this if the use case could be explained.
Hi @csvan ,
I apologize for the late reply. I added it in response to this issue, but otherwise had no strong motivation for it. Professionally, I've never had to use flushSync
, so I'm not familiar with its caveats/pitfalls. Would be happy to see a PR from you to remove it if you don't think it is necessary anymore!