Yuken Tezuka 3 лет назад
Родитель
Сommit
84a481ea7b
1 измененных файлов с 7 добавлено и 4 удалено
  1. 7 4
      packages/app/src/components/PageEditor/Editor.tsx

+ 7 - 4
packages/app/src/components/PageEditor/Editor.tsx

@@ -260,14 +260,17 @@ const Editor: ForwardRefRenderFunction<IEditorMethods, EditorPropsType> = (props
     );
   }, [isCheatsheetModalShown]);
 
+  const isReadyToRenderEditor = editorSettings != null;
+  const editorRef = editorSubstance();
+
   useEffect(() => {
-    if (editorSubstance != null && editorSettings != null) {
-      const editorNavBarItems = editorSubstance()?.getNavbarItems() ?? [];
+    if (isReadyToRenderEditor && editorRef != null) {
+      const editorNavBarItems = editorRef.getNavbarItems() ?? [];
       setNavBarItems(editorNavBarItems);
     }
-  }, [editorSettings, editorSubstance]);
+  }, [editorRef, isReadyToRenderEditor]);
 
-  if (editorSettings == null) {
+  if (!isReadyToRenderEditor) {
     return <></>;
   }