@@ -16,6 +16,7 @@ import Letter from './components/Letter';
1616import { useNavigate , useParams } from 'react-router' ;
1717import useAuthStore from '@/stores/authStore' ;
1818import useToastStore from '@/stores/toastStore' ;
19+ import { useQueryClient } from '@tanstack/react-query' ;
1920
2021const 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