diff --git a/packages/editor/src/hooks/use-editor.ts b/packages/editor/src/hooks/use-editor.ts index 89e9d3214..3235a7fe4 100644 --- a/packages/editor/src/hooks/use-editor.ts +++ b/packages/editor/src/hooks/use-editor.ts @@ -34,6 +34,7 @@ export const useEditor = ( const [editor, setEditor] = useState(null); const forceUpdate = useForceUpdate(); const editorRef = useRef(editor); + const updateTimeout = useRef(); useEffect( () => { @@ -44,13 +45,16 @@ export const useEditor = ( setEditor(instance); instance.on("transaction", () => { - requestAnimationFrame(() => { + clearTimeout(updateTimeout.current); + updateTimeout.current = setTimeout(() => { requestAnimationFrame(() => { - if (isMounted) { - forceUpdate(); - } + requestAnimationFrame(() => { + if (isMounted) { + forceUpdate(); + } + }); }); - }); + }, 100) as unknown as number; }); return () => {