Просмотр исходного кода

fix useEffect to mutate current tocNode

Yuki Takei 3 лет назад
Родитель
Сommit
c1efa5380e
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      packages/app/src/components/Page.tsx

+ 3 - 1
packages/app/src/components/Page.tsx

@@ -235,7 +235,9 @@ export const Page = (props) => {
   }, [mutateRendererOptions]);
 
   useEffect(() => {
-    mutateCurrentPageTocNode(tocRef.current);
+    if (tocRef.current != null) {
+      mutateCurrentPageTocNode(tocRef.current);
+    }
   // eslint-disable-next-line react-hooks/exhaustive-deps
   }, [mutateCurrentPageTocNode, tocRef.current]); // include tocRef.current to call mutateCurrentPageTocNode when tocRef.current changes