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

Wrap onCommentEdited in useCallback (#17379)

GitOrigin-RevId: 3171ed2a50502d0771457a3f3547eacec33efa20
Alf Eaton 2 лет назад
Родитель
Сommit
b608c5eae6

+ 11 - 12
services/web/frontend/js/features/ide-react/context/review-panel/hooks/use-review-panel-state.ts

@@ -956,19 +956,18 @@ function useReviewPanelState(): ReviewPanelStateReactIde {
     [onThreadDeleted, projectId]
   )
 
-  const onCommentEdited: ReviewPanel.UpdaterFn<'saveEdit'> = (
-    threadId: ThreadId,
-    commentId: CommentId,
-    content: string
-  ) => {
-    setCommentThreads(prevState => {
-      const thread = { ...getThread(threadId) }
-      thread.messages = thread.messages.map(message => {
-        return message.id === commentId ? { ...message, content } : message
+  const onCommentEdited = useCallback(
+    (threadId: ThreadId, commentId: CommentId, content: string) => {
+      setCommentThreads(prevState => {
+        const thread = { ...getThread(threadId) }
+        thread.messages = thread.messages.map(message => {
+          return message.id === commentId ? { ...message, content } : message
+        })
+        return { ...prevState, [threadId]: thread }
       })
-      return { ...prevState, [threadId]: thread }
-    })
-  }
+    },
+    [getThread]
+  )
 
   const saveEdit = useCallback(
     (threadId: ThreadId, commentId: CommentId, content: string) => {