From 035a627a14f84f88e824be7539906648a2253dea Mon Sep 17 00:00:00 2001 From: Brian Kim Date: Sun, 2 Feb 2025 08:23:00 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8add=20reload=20when=20editing=20commen?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CommentEditWindow.tsx | 2 ++ src/components/CommentItem.tsx | 3 ++- src/pages/CommunityPostPage.tsx | 8 +++++++- src/typings/communityPost.ts | 2 ++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/components/CommentEditWindow.tsx b/src/components/CommentEditWindow.tsx index 1ba31a0..5705959 100644 --- a/src/components/CommentEditWindow.tsx +++ b/src/components/CommentEditWindow.tsx @@ -11,6 +11,7 @@ import type { CommentEditWindowProps } from '../typings/communityPost'; const CommentEditWindow = ({ CommentInfo, closeWindow, + onCommentEdit, }: CommentEditWindowProps) => { const [commentBody, setCommentBody] = useState(CommentInfo.content); @@ -36,6 +37,7 @@ const CommentEditWindow = ({ } closeWindow(); + onCommentEdit(); } catch (error) { console.error('수정 중 에러 발생:', error); } diff --git a/src/components/CommentItem.tsx b/src/components/CommentItem.tsx index 38f02b0..35203e4 100644 --- a/src/components/CommentItem.tsx +++ b/src/components/CommentItem.tsx @@ -14,7 +14,7 @@ import { getTimeAgo } from '../utils/utils'; import CommentEditWindow from './CommentEditWindow'; import Overlay from './Overlay'; -const Comment = ({ CommentInfo }: CommentProps) => { +const Comment = ({ CommentInfo, onCommentEdit }: CommentProps) => { const [isOverlayOpen, setIsOverlayOpen] = useState(false); const [isCommentEditOpen, setIsCommentEditOpen] = useState(false); const [isLiked, setIsLiked] = useState(CommentInfo.isLiked); @@ -186,6 +186,7 @@ const Comment = ({ CommentInfo }: CommentProps) => { closeWindow={() => { setIsCommentEditOpen(false); }} + onCommentEdit={onCommentEdit} /> )} diff --git a/src/pages/CommunityPostPage.tsx b/src/pages/CommunityPostPage.tsx index 6f8129f..810466d 100644 --- a/src/pages/CommunityPostPage.tsx +++ b/src/pages/CommunityPostPage.tsx @@ -352,7 +352,13 @@ const CommunityPostPage = () => { : 0; }) .map((Comment, index) => ( - + { + void fetchPost(); + }} + /> ))} )} diff --git a/src/typings/communityPost.ts b/src/typings/communityPost.ts index 148a7d0..9a90513 100644 --- a/src/typings/communityPost.ts +++ b/src/typings/communityPost.ts @@ -40,11 +40,13 @@ type Comment = { export type CommentProps = { CommentInfo: Comment; + onCommentEdit: () => void; }; export type CommentEditWindowProps = { CommentInfo: Comment; closeWindow: () => void; + onCommentEdit: () => void; }; export const TagsArray = [