-
-
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
useEditor returning null #2182
Comments
This is intended because the editor instance is created after mounting your component (which is needed because tiptap needs access to the DOM). tiptap/packages/react/src/useEditor.ts Lines 15 to 31 in bc242fe
If you need the editor instance in your template you have to check if editor is not null. After mounting, your component should be re-rendered so this shouldn’t be an issue at all. |
I have a PR that makes sure the editor is available on the first render: #2282 |
…s#2282), fix ueberdosis#2040, fix ueberdosis#2182" This reverts commit 2436e2c.
What’s the bug you are facing?
I'm trying to use
useEditor
, but it returns null at first, and then returns an Editor object. I create it and log the variable I set it to immediately, and it prints out null first, and then it prints out the Editor object. I am using create-react-app in React.How can we reproduce the bug on our side?
App.js
before the return statement:If the issue persists, it will print null first, and then the Editor object afterwards.
Can you provide a CodeSandbox?
Here you go
What did you expect to happen?
There shouldn't be a null, the Editor object should be the only thing being printed
Anything to add? (optional)
This issue makes it difficult when I want to use the editor object in other parts of my UI, like using its
getText()
method.Did you update your dependencies?
Are you sponsoring us?
The text was updated successfully, but these errors were encountered: