瀏覽代碼

Implement useMemo to getChildCount method

https://youtrack.weseek.co.jp/issue/GW-7849
- Implement useMemo to getChildCount method
Mudana-Grune 3 年之前
父節點
當前提交
6ba9ccc32d
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      packages/app/src/components/Bookmarks/BookmarkFolderItem.tsx

+ 3 - 3
packages/app/src/components/Bookmarks/BookmarkFolderItem.tsx

@@ -1,5 +1,5 @@
 import {
 import {
-  FC, useCallback, useEffect, useState,
+  FC, useCallback, useEffect, useState, useMemo,
 } from 'react';
 } from 'react';
 
 
 import { useTranslation } from 'next-i18next';
 import { useTranslation } from 'next-i18next';
@@ -38,7 +38,7 @@ const BookmarkFolderItem: FC<BookmarkFolderItemProps> = (props: BookmarkFolderIt
   const [isCreateAction, setIsCreateAction] = useState<boolean>(false);
   const [isCreateAction, setIsCreateAction] = useState<boolean>(false);
   const [isDeleteFolderModalShown, setIsDeleteFolderModalShown] = useState<boolean>(false);
   const [isDeleteFolderModalShown, setIsDeleteFolderModalShown] = useState<boolean>(false);
 
 
-  const getChildCount = useCallback((): number => {
+  const getChildCount = useMemo((): number => {
     if (currentChildren != null && currentChildren.length > children.length) {
     if (currentChildren != null && currentChildren.length > children.length) {
       return currentChildren.length;
       return currentChildren.length;
     }
     }
@@ -188,7 +188,7 @@ const BookmarkFolderItem: FC<BookmarkFolderItemProps> = (props: BookmarkFolderIt
             </div>
             </div>
             {hasChildren() && (
             {hasChildren() && (
               <div className="grw-foldertree-count-wrapper">
               <div className="grw-foldertree-count-wrapper">
-                <CountBadge count={ getChildCount() } />
+                <CountBadge count={ getChildCount } />
               </div>
               </div>
             )}
             )}
           </>
           </>