React-codemirror with yjs + y-websocket last line does not sync properly

Welcome to the discussion board @pakatahwa,

Unfortunately, this is too much code for me to debug. Can you reproduce the issue on pure CodeMirror without React and all the reactive data handling?

You probably shouldn’t reset the CodeMirror state on every transaction (setCodeMirrorText).

The effect handler doesn’t seem to delete old state. When useEffect is called multiple times, you will create multiple editor bindings. You should destroy the provider and the binding when you don’t reference them anymore (i.e. x.destroy()).