Setting initial y-websocket content saved as markdown in DB

I noticed in this thread the suggestion to work with document updates rather than text updates. So I’ve also tried the following with the same result. I’m still seeing content get overwritten in the template with empty text

  useMemo(() => {
    const ydoc = new Y.Doc();

    defaultValue && ydoc.getText().insert(0, defaultValue);

    yXmlFragment.current = ydoc.getXmlFragment("prosemirror");

    provider.current = new WebsocketProvider(
      "wss://my-y-websockets.herokuapp.com",
      `${docID}`,
      ydoc
    );

    if (provider.current.shouldConnect) {
      provider.current.connect();
    } else {
      provider.current.disconnect();
    }

    provider.current.on("synced", () => {
      // received the initial content from socket, so allow editor render
      setYjsLoaded(true);
    });

    return () => {
      provider.current?.disconnect();
    };
  }, [defaultValue, docID]);