react-use-websocket icon indicating copy to clipboard operation
react-use-websocket copied to clipboard

Rationale for using flushSync?

Open csvan opened this issue 1 year ago • 1 comments

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.

csvan avatar Oct 14 '23 08:10 csvan

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!

robtaussig avatar Feb 28 '24 19:02 robtaussig