So im using the Codemirror 6 demo code in a react component, it works fine but when I refresh the tab several times the contents get removed idk why.
PS: im using y-mongodb-provider to persist the Ydocs in backend
It may be that your backend link is not persistent the Ydoc, causing the websocket connection to be detected after a refresh that triggers the destruction of the Ydoc object
Thanks for the comment @dmonad. Why do you think its related to y-mongodb-provider?
Correct me if im wrong but AFAIK the yDoc exists on both server and clients, the y-websocket server was up the whole time. So on each client refresh it should pull the yDoc from the server rather than overwriting it.
I also tried to reproduce this with websocket server with LevelDB persistence with this command and found the same result HOST=localhost PORT=3334 YPERSISTENCE=./dbDir node ./node_modules/y-websocket/bin/server.cjs
After many attempts I made it work with vite + react. It works perfectly but the issue still exist when I reproduce it in a nextjs project (on which my entire project is based on).
Here are the things that I’ve observed so far.
I thought that this could be due to SSR but importing the component using const Comp = dynamic(()=>import("./Comp.tsx"), {ssr: false} still gives the same issue.
Only importing the component with yjs deps on client gives same issue
let Comp;
if (typeof window !== "undefined") {
Comp = require("./Comp").default;
}