-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Option to make editor available during initial render of hook. #2287
Option to make editor available during initial render of hook. #2287
Conversation
✔️ Deploy Preview for tiptap-embed ready! 🔨 Explore the source changes: 0f76732 🔍 Inspect the deploy log: https://app.netlify.com/sites/tiptap-embed/deploys/61bbaa8166df7e000742e480 😎 Browse the preview: https://deploy-preview-2287--tiptap-embed.netlify.app |
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.
This looks good to me! Nice @ryanto
Can’t we detect the Node environment, e.g. by checking for the presence of document? |
Issue is that the server render needs to match the first client side render. If the server render doesn't have I think the long term solution here is to make it so the HTML generated by the editor is renderable on the server... specifically you can take an editor's content and generate its HTML server side without setting up the content editable, events, or referencing browser APIs, but that seems like a bigger task. This PR is just a stop gap to allow for an initial render on the client that has the editor. I could also make a new hook like |
By the way, just wanted to add that I realize all of this is super confusing and throwing in options like I have this hook locally in my app that I'm using as a stop gap to get client side initial renders of tiptap. When people run into issues like #2040 or #2182 we can direct them to that gist as a fix instead of adding options to useEditor. |
Also this is a great read on rehydration, client-server mismatch, and how useEffect helps control what's rendered on the server and initial client renders. https://www.joshwcomeau.com/react/the-perils-of-rehydration/ |
Okay, sometimes you should just sleep on it. I think that an |
This PR is a fix for #2282 that allows the user to opt into having the editor available during the first render. We're making it opt in because the Editor doesn't render on the server (it expects
document
to exist), so enabling this by default would crash server rendered apps.