Browse Source

Merge branch 'feat/pt-dev-3' into feat/impl-triangle-button

Taichi Masuyama 4 years ago
parent
commit
f7588e8391

+ 9 - 4
packages/app/src/components/Sidebar/PageTree/Item.tsx

@@ -49,15 +49,20 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
     if (hasChildren()) setIsOpen(true);
   }, []);
 
-  // make sure itemNode.children and currentChildren are synced
+  /*
+   * Make sure itemNode.children and currentChildren are synced
+   */
   useEffect(() => {
     if (children.length > currentChildren.length) {
       markTarget(children, targetId);
       setCurrentChildren(children);
     }
-    /*
-     * When swr fetch succeeded
-     */
+  }, []);
+
+  /*
+   * When swr fetch succeeded
+   */
+  useEffect(() => {
     if (isOpen && error == null && data != null) {
       const newChildren = ItemNode.generateNodesFromPages(data.children);
       markTarget(newChildren, targetId);

+ 1 - 1
packages/app/src/components/Sidebar/PageTree/ItemsTree.tsx

@@ -51,7 +51,7 @@ const ItemsTree: FC = () => {
 
   const { data, error } = useTargetAndAncestors();
 
-  const { data: ancestorsChildrenData, error: error2 } = useSWRxPageAncestorsChildren(currentPath == null ? null : currentPath);
+  const { data: ancestorsChildrenData, error: error2 } = useSWRxPageAncestorsChildren(currentPath || null);
 
   if (error != null || error2 != null) {
     return null;