Skip to content

Commit 081463e

Browse files
committed
fix: 예약내역 페이지 진입 시 API 재호출되게 수정
1 parent 28b33d4 commit 081463e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/app/mypage/reservation-list/page.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@ import { Badge } from '@/components/ui/badge';
44

55
import { Label } from '@/components/ui/label';
66
import { reservationStatusAll, ReservationStatusWithAll } from '@/lib/constants/reservation';
7-
import { useState } from 'react';
7+
import { useQueryClient } from '@tanstack/react-query';
8+
import { usePathname } from 'next/navigation';
9+
import { useEffect, useState } from 'react';
810

911
const ReservationListPage = () => {
12+
const queryClient = useQueryClient();
13+
const pathname = usePathname();
1014
const [selectedStatus, setSelectedStatus] = useState<ReservationStatusWithAll>('all');
1115

16+
useEffect(() => {
17+
queryClient.invalidateQueries({ queryKey: ['reservation-list', selectedStatus] });
18+
}, [pathname, selectedStatus, queryClient]);
19+
1220
return (
1321
<div className='flex flex-col gap-7.5'>
1422
{/* 헤더 */}

src/hooks/useInfiniteReservationList.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ const useInfiniteReservationList = (
3636

3737
return lastPage.cursorId;
3838
},
39-
// refetchOnMount: true,
4039
});
4140

4241
const reservationListData = useMemo(() => {

0 commit comments

Comments
 (0)