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

Implement useMemo to getChildCount method

https://youtrack.weseek.co.jp/issue/GW-7849
- Implement useMemo to getChildCount method
Mudana-Grune 3 лет назад
Родитель
Сommit
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 {
-  FC, useCallback, useEffect, useState,
+  FC, useCallback, useEffect, useState, useMemo,
 } from 'react';
 
 import { useTranslation } from 'next-i18next';
@@ -38,7 +38,7 @@ const BookmarkFolderItem: FC<BookmarkFolderItemProps> = (props: BookmarkFolderIt
   const [isCreateAction, setIsCreateAction] = useState<boolean>(false);
   const [isDeleteFolderModalShown, setIsDeleteFolderModalShown] = useState<boolean>(false);
 
-  const getChildCount = useCallback((): number => {
+  const getChildCount = useMemo((): number => {
     if (currentChildren != null && currentChildren.length > children.length) {
       return currentChildren.length;
     }
@@ -188,7 +188,7 @@ const BookmarkFolderItem: FC<BookmarkFolderItemProps> = (props: BookmarkFolderIt
             </div>
             {hasChildren() && (
               <div className="grw-foldertree-count-wrapper">
-                <CountBadge count={ getChildCount() } />
+                <CountBadge count={ getChildCount } />
               </div>
             )}
           </>