fix editor cleanup (#4973)

This commit is contained in:
Karol Firmanty 2024-04-06 04:02:05 +02:00 committed by GitHub
parent 1439a91624
commit 8d5077a1a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
}