Skip to content

Commit 403ecc3

Browse files
committed
fix: 게시물 삭제후 리스트 반영
1 parent 26a9716 commit 403ecc3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/pages/LetterBoardDetail/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Letter from './components/Letter';
1616
import { useNavigate, useParams } from 'react-router';
1717
import useAuthStore from '@/stores/authStore';
1818
import useToastStore from '@/stores/toastStore';
19+
import { useQueryClient } from '@tanstack/react-query';
1920

2021
const LetterBoardDetailPage = () => {
2122
const [likeCount, setLikeCount] = useState(0);
@@ -27,13 +28,14 @@ const LetterBoardDetailPage = () => {
2728
const { id } = useParams();
2829
const myZipCode = useAuthStore.getState().zipCode;
2930
const setToastActive = useToastStore((state) => state.setToastActive);
31+
3032
const navigate = useNavigate();
33+
const queryClient = useQueryClient();
3134

3235
const postLike = async (sharePostId: string) => {
3336
try {
3437
const response = await postSharePostLike(sharePostId);
3538
if (!response) throw new Error('error while fetching like count');
36-
console.log('✅ 편지 좋아요 추가됨:', response);
3739
} catch (error) {
3840
console.error('❌ 편지 좋아요 추가 중 에러가 발생했습니다', error);
3941
}
@@ -53,6 +55,7 @@ const LetterBoardDetailPage = () => {
5355
if (id) {
5456
const response = await deleteSharePost(id);
5557
if (!response) throw new Error('deleteSharePost: no response');
58+
queryClient.invalidateQueries({ queryKey: ['sharePostList'] });
5659
navigate(-1);
5760
setToastActive({
5861
toastType: 'Success',

0 commit comments

Comments
 (0)