Skip to content

Commit 07dd786

Browse files
committed
[FIX] 답댓글 작성/삭제 시 새로고침 추가
1 parent 5c6fed3 commit 07dd786

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/components/post/Comment.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import axios from "axios";
1010
const token = localStorage.getItem("accessToken");
1111
const muit_server = import.meta.env.VITE_APP_SERVER_URL;
1212

13-
function Comment({data, noneCommentIcon, isDeleted, setIsDeleted}) {
13+
function Comment({data, noneCommentIcon, isDeleted, setIsDeleted, isWrited, setIsWrited}) {
1414
// console.log('Comment.jsx', data);
1515
const [isWriter, setIsWriter] = useState(data.nickname=='글쓴이');
1616

@@ -153,15 +153,15 @@ function Comment({data, noneCommentIcon, isDeleted, setIsDeleted}) {
153153
{Array.isArray(data.replies) && data.replies.length > 0 ? (
154154
<ReplyWrapper>
155155
{data?.replies?.map((reply) => (
156-
<Reply key={reply.id} data={reply} />
156+
<Reply key={reply.id} data={reply} setIsDeleted={setIsDeleted} isDeleted={isDeleted}/>
157157
))}
158158
</ReplyWrapper>
159159
) : null}
160160
{isReplying && (
161161
<ReplyInputWrapper>
162162
<img src={ReplyArrow} />
163163
<div style={{width: '100%'}}>
164-
<CommentInputArea postId={data.commentId} isReplying={isReplying} setIsReplying={setIsReplying} />
164+
<CommentInputArea postId={data.commentId} isReplying={isReplying} setIsReplying={setIsReplying} isWrited={isWrited} setIsWrited={setIsWrited}/>
165165
</div>
166166

167167
</ReplyInputWrapper>

src/components/post/Reply.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useState } from "react";
77
import axios from "axios";
88
const token = localStorage.getItem("accessToken");
99
const muit_server = import.meta.env.VITE_APP_SERVER_URL;
10-
function Reply({key, data}) {
10+
function Reply({key, data, isDeleted, setIsDeleted}) {
1111
console.log(data);
1212
console.log('리플라이 콘텐츠', data.content);
1313

@@ -32,6 +32,7 @@ function Reply({key, data}) {
3232

3333
if (response.ok) {
3434
alert("댓글이 삭제되었습니다.");
35+
setIsDeleted(!isDeleted);
3536
// 필요하면 상태 업데이트 로직 추가
3637
} else {
3738
alert(`삭제 실패: ${result.message}`);

src/pages/board/post/AnonymousPost.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ function AnonymousPost() {
172172
<CommentInputArea postId={postId} setCommentTrigger={setCommentTrigger} commentTrigger={commentTrigger} isWrited={isWrited} setIsWrited={setIsWrited}/>
173173
<CommentWrapper>
174174
{comment?.result?.comments?.map((data) => (
175-
<Comment key={data.commentId} data={data} isDeleted={isDeleted} setIsDeleted={setIsDeleted}/>
175+
<Comment key={data.commentId} data={data} isDeleted={isDeleted} setIsDeleted={setIsDeleted} isWrited={isWrited} setIsWrited={setIsWrited}/>
176176
))}
177177
</CommentWrapper>
178178

0 commit comments

Comments
 (0)