-
-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
useRemoteCursorOverlayPositions in react 18 does not work #372
Comments
In @slate-yjs/react@0.2.4 it seems react 18 worked |
That only occurs for me if I'm editing at the end of a line my guess: RemoteCursorOverlay is updating before the document is in sync |
Could you share a reproducible example of it not working? Just tested bumping the example and it seems to be working there without any issues |
@BitPhinix Here not working example in my fork https://github.com/ilya2204/slate-yjs/tree/not-working-example slate-yjs.-.Google.Chrome.-.20.November.2022.mp4 |
Ahaha, I forgot to switch over to |
It seems like this issue may have to do with React 18's automatic batching. I've been looking into this for a couple of days, and noticed that the editor state seems to be behind the DOM state. I've been able to work around this (hopefully temporarily) by disabling automatic batching during changes. This is really hacky, but it seems to solve the issue:
Hopefully this helps someone! |
Hi, thank you for this solution. However, I noticed that this causes a warning about flushSync getting called inside a lifecycle function, is this okay or will it cause problems going forward? |
I haven't seen any problems on my end, but it's definitely not an ideal solution (the internal components should properly handle batching). I'm using it as a stopgap. |
Facing this same issue. Unfortunately in my case, I am mounting the Editor only after my HocusPocus Provider has synced so even before flushSync is used with onChange, my editor crashes. This is a work around to issue with Initial State conflict - #111 and #385 Crash Scenario:User A already has an active selection. I am temporarily running React in v17 by using ReactDOM.render as a workaround as suggested in #374 @BitPhinix Have you been able to probe deeper into this? |
same issue as well on my end using Plate to mount when the HocusPocus Provider synced.
|
Might help someone else but it seems I am able to fix this on my end without downgrading to v17 by using useLayoutEffect
|
Hello! useRemoteCursorOverlayPositions doesn't seem to work in react 18. In the simplest setup with the withCursors plugin, when a remote user types, an error occurs. Maybe the plugin does not support react 18, but I did not find any information about this. (When I switched to version 17 everything worked as it should)
The text was updated successfully, but these errors were encountered: