mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-27 23:15:15 +08:00
fix(react): if using a deps array, destroy the previous instance
This commit is contained in:
parent
b012471755
commit
42dc27aa4b
5
.changeset/funny-walls-mix.md
Normal file
5
.changeset/funny-walls-mix.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@tiptap/react": patch
|
||||
---
|
||||
|
||||
Fix, if using a deps array destroy the previous instance to avoid ghost instances
|
@ -106,6 +106,10 @@ export function useEditor(
|
||||
// for ssr, this is the first time the editor is created
|
||||
setEditor(editorInstance)
|
||||
} else if (Array.isArray(deps) && deps.length) {
|
||||
// We need to destroy the editor instance and re-initialize it
|
||||
// when the deps array changes
|
||||
editorInstance.destroy()
|
||||
|
||||
// the deps array is used to re-initialize the editor instance
|
||||
editorInstance = new Editor(options)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user