Quellcode durchsuchen

Implement useCallback

https://youtrack.weseek.co.jp/issue/GW-7840
- Implement useCallback for pressEnterForRenameHandler
- Import missing useState
Mudana-Grune vor 3 Jahren
Ursprung
Commit
1b24af7d65
1 geänderte Dateien mit 3 neuen und 3 gelöschten Zeilen
  1. 3 3
      packages/app/src/components/Sidebar/Bookmarks.tsx

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

@@ -1,5 +1,5 @@
 
 
-import React, { useCallback } from 'react';
+import React, { useCallback, useState } from 'react';
 
 
 import nodePath from 'path';
 import nodePath from 'path';
 
 
@@ -52,7 +52,7 @@ const BookmarkItem = (props: Props) => {
     return null;
     return null;
   };
   };
 
 
-  const pressEnterForRenameHandler = (async(inputText: string) => {
+  const pressEnterForRenameHandler = useCallback(async(inputText: string) => {
     const parentPath = pathUtils.addTrailingSlash(nodePath.dirname(bookmarkedPage.path ?? ''));
     const parentPath = pathUtils.addTrailingSlash(nodePath.dirname(bookmarkedPage.path ?? ''));
     const newPagePath = nodePath.resolve(parentPath, inputText);
     const newPagePath = nodePath.resolve(parentPath, inputText);
     if (newPagePath === bookmarkedPage.path) {
     if (newPagePath === bookmarkedPage.path) {
@@ -74,7 +74,7 @@ const BookmarkItem = (props: Props) => {
       setRenameInputShown(true);
       setRenameInputShown(true);
       toastError(err);
       toastError(err);
     }
     }
-  });
+  }, [bookmarkedPage, onPageOperationSuccess, t]);
 
 
   return (
   return (
     <div className="d-flex justify-content-between" key={bookmarkedPage._id}>
     <div className="d-flex justify-content-between" key={bookmarkedPage._id}>