From 4c0f13e2a61e4f8633406e513d2b099930ff1ef7 Mon Sep 17 00:00:00 2001 From: Nick the Sick Date: Thu, 23 May 2024 19:29:41 +0200 Subject: [PATCH] fix: move useEffect up --- packages/react/src/useEditor.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/react/src/useEditor.ts b/packages/react/src/useEditor.ts index 778bf5756dc..865925f4d68 100644 --- a/packages/react/src/useEditor.ts +++ b/packages/react/src/useEditor.ts @@ -204,6 +204,18 @@ function useEditor(options: UseEditorOptions = useDebugValue(editor) + // This effect will handle creating/updating the editor instance + useEffect(() => { + if (!editor) { + // instantiate the editor if it doesn't exist + // for ssr, this is the first time the editor is created + editorInstance.create(options) + } else { + // if the editor does exist, update the editor options accordingly + editor.setOptions(options) + } + }, deps) + const { onBeforeCreate, onBlur, @@ -297,18 +309,6 @@ function useEditor(options: UseEditorOptions = } }, [onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, onContentError, editor]) - // This effect will handle creating/updating the editor instance - useEffect(() => { - if (!editor) { - // instantiate the editor if it doesn't exist - // for ssr, this is the first time the editor is created - editorInstance.create(options) - } else { - // if the editor does exist, update the editor options accordingly - editor.setOptions(options) - } - }, deps) - /** * Destroy the editor instance when the component completely unmounts * As opposed to the cleanup function in the effect above, this will