mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-24 03:39:01 +08:00
fix editor cleanup (#4973)
This commit is contained in:
parent
1439a91624
commit
8d5077a1a5
@ -99,7 +99,8 @@ export const useEditor = (options: Partial<EditorOptions> = {}, deps: Dependency
|
||||
useEffect(() => {
|
||||
let isMounted = true
|
||||
|
||||
editorRef.current = new Editor(options)
|
||||
const editor = new Editor(options)
|
||||
editorRef.current = editor
|
||||
|
||||
editorRef.current.on('transaction', () => {
|
||||
requestAnimationFrame(() => {
|
||||
@ -113,14 +114,9 @@ export const useEditor = (options: Partial<EditorOptions> = {}, deps: Dependency
|
||||
|
||||
return () => {
|
||||
isMounted = false
|
||||
editor.destroy()
|
||||
}
|
||||
}, deps)
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
return editorRef.current?.destroy()
|
||||
}
|
||||
}, [])
|
||||
|
||||
return editorRef.current
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user