fix: solve the problem that comments cannot be deleted

This commit is contained in:
robin 2023-01-09 17:35:59 +08:00
parent 5617a4eb0e
commit 4a40f77c56
1 changed files with 2 additions and 3 deletions

View File

@ -35,7 +35,7 @@ const Comment = ({ objectId, mode, commentId }) => {
page: pageIndex,
page_size: pageSize,
});
const [comments, setComments] = useState<any>(data?.list || []);
const [comments, setComments] = useState<any>([]);
const reportModal = useReportModal();
@ -167,9 +167,8 @@ const Comment = ({ objectId, mode, commentId }) => {
deleteComment(id).then(() => {
if (pageIndex === 0) {
mutate();
} else {
setComments(comments.filter((item) => item.comment_id !== id));
}
setComments(comments.filter((item) => item.comment_id !== id));
});
},
});