diff --git a/packages/react/src/useEditor.ts b/packages/react/src/useEditor.ts index 883a4a230..b6a090b6e 100644 --- a/packages/react/src/useEditor.ts +++ b/packages/react/src/useEditor.ts @@ -14,6 +14,8 @@ export const useEditor = (options: Partial = {}, deps: Dependency const forceUpdate = useForceUpdate() useEffect(() => { + let isMounted = true + const instance = new Editor(options) setEditor(instance) @@ -21,13 +23,16 @@ export const useEditor = (options: Partial = {}, deps: Dependency instance.on('transaction', () => { requestAnimationFrame(() => { requestAnimationFrame(() => { - forceUpdate() + if (isMounted) { + forceUpdate() + } }) }) }) return () => { instance.destroy() + isMounted = false } }, deps)