-
Notifications
You must be signed in to change notification settings - Fork 27
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
add indexdb integration to yjs hooks #3
add indexdb integration to yjs hooks #3
Conversation
DIS-1140 Add IndexDB integration to yjs hooks
https://github.com/yjs/y-indexeddb This will allow the document to be persisted offline. |
return useContext(YjsContext)?.doc ?? null | ||
export function useYDoc(): Y.Doc { | ||
const yjsCtx = useContext(YjsContext) | ||
if (!yjsCtx) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does React guarantee that useEffect
in YDocProvider
will have been called before the component that invokes useYDoc
is rendered? Otherwise this will be null
even if it is in the provider on the first render, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are enforcing that by not rendering the Provider's children until the useEffect has run and the ctx !== null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh, that makes sense, I can see how this is better!
3d4ef16
to
2d4115b
Compare
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
First 3 commits contain some small refactoring. A description for each change is in the commit messages.
Adding IndexDBProvider is still WIP