Fix broken React unmount because of non-existing view on unmount (#6284)

* fixed a bug with the React EditorContent component on unmount when editor view not available

* added changeset
This commit is contained in:
bdbch 2025-04-22 16:15:50 +02:00 committed by GitHub
parent ef3a7e497c
commit 3aa670a788
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 4 deletions

View File

@ -0,0 +1,5 @@
---
'@tiptap/react': patch
---
Fixed a bug in the EditorContent component that caused a crash in Firefox based browsers because of the editor view not being available when an uninitialized editor is unmounted (for example via Strict mode)

View File

@ -164,10 +164,14 @@ export class PureEditorContent extends React.Component<
this.initialized = false
if (!editor.isDestroyed) {
editor.view.setProps({
nodeViews: {},
})
try {
if (!editor.isDestroyed) {
editor.view.setProps({
nodeViews: {},
})
}
} catch {
// ignore error as we can't set props on a non-existing view
}
if (this.unsubscribeToContentComponent) {