From 3edf20023fb09744333b8fad5cac6daed6eb2ba8 Mon Sep 17 00:00:00 2001 From: GeoSyntax Date: Tue, 23 Jun 2026 01:45:28 +0800 Subject: [PATCH] fix: use immutable update for comment vote state --- ui/src/components/Comment/index.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ui/src/components/Comment/index.tsx b/ui/src/components/Comment/index.tsx index af2ddbd4f..b294c2e13 100644 --- a/ui/src/components/Comment/index.tsx +++ b/ui/src/components/Comment/index.tsx @@ -311,10 +311,13 @@ const Comment: FC = ({ objectId, mode, commentId, children }) => { setComments( comments.map((item) => { if (item.comment_id === id) { - item.vote_count = is_cancel - ? item.vote_count - 1 - : item.vote_count + 1; - item.is_vote = !is_cancel; + return { + ...item, + vote_count: is_cancel + ? item.vote_count - 1 + : item.vote_count + 1, + is_vote: !is_cancel, + }; } return item; }),