SebastianStehle / yjs-redux

MIT License
13 stars 1 forks source link

error when passing a document to connectSlice #6

Open fredericrous opened 8 months ago

fredericrous commented 8 months ago

the code:

const ydoc = new Y.Doc();
new IndexeddbPersistence('my-room', ydoc)
binder.connectSlice({
    document: ydoc,
    sliceName: 'my-slice'
});

the error

Error: Root object must be an object, got object.
    at Fe (/my-project/packages/yjs-redux/lib/binder-hooks.ts:4493:13)
    at G (/my-project/packages/yjs-redux/lib/binder-hooks.ts:4463:16)
    at Ji (/my-project/packages/yjs-redux/lib/binder-hooks.ts:4560:3)
    at /my-project/packages/yjs-redux/lib/binder-hooks.ts:4813:9
    at /my-project/packages/yjs-redux/lib/binder-hooks.ts:4822:11
    at transact (file:///my-project/node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/yjs.mjs:3354:14)
    at Doc.transact (file:///my-project/node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/yjs.mjs:525:12)
    at qi.transact (/my-project/packages/yjs-redux/lib/binder-hooks.ts:4820:36)
    at qi.connect (/my-project/packages/yjs-redux/lib/binder-hooks.ts:4812:12)
    at middleware (/my-project/packages/yjs-redux/lib/binder-hooks.ts:4717:9)
    at file:///my-project/node_modules/.pnpm/redux@5.0.0/node_modules/redux/dist/redux.mjs:373:51

most likey the problematic code looks to be https://github.com/SebastianStehle/yjs-redux/blob/33d37107dbacbc1e06a563f93a585f0e26a25890/lib/sync-to-yjs.ts#L66-L69

SebastianStehle commented 8 months ago

How have you constructed the document and root? The root is probably an array and the typeof is not very accurate.