Skip to content

Commit ac3dec6

Browse files
committed
fix : reactquery 수정
1 parent 9c62af2 commit ac3dec6

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

src/pages/Volunteer/Application.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,21 @@ export const VolunteerApplication = () => {
1717
initTheme.get('theme') === 'dark' ? THEME.DARK : THEME.LIGHT,
1818
);
1919

20-
const { data } = useGetVolunteer();
20+
const { data, isLoading, isError } = useGetVolunteer();
2121

2222
const [applications, setApplications] = useState<any[]>([]);
2323

2424
useEffect(() => {
25-
console.log('연동 성공! 데이터:', data);
26-
setApplications(data?.volunteers || []);
27-
}, [data]);
25+
if (isLoading) return;
26+
if (isError) {
27+
console.error('봉사 데이터 불러오기 실패함');
28+
return;
29+
}
30+
if (data) {
31+
console.log('연동 성공! 데이터:', data);
32+
setApplications(data.volunteers || []);
33+
}
34+
}, [data, isLoading, isError]);
2835

2936
const removeApplication = (volunteerId: string) => {
3037
setApplications((prevApplications) =>

src/pages/Volunteer/History.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,19 @@ export const VolunteerHistory = () => {
1919
initTheme.get('theme') === 'dark' ? THEME.DARK : THEME.LIGHT,
2020
);
2121

22-
const { data } = useGetMyVolunteers();
22+
const { data, isLoading, isError } = useGetMyVolunteers();
2323

2424
useEffect(() => {
25-
console.log('연동 성공! 데이터:', data);
26-
setHistories(data?.volunteer_applications || []);
27-
}, [data]);
25+
if (isLoading) return;
26+
if (isError) {
27+
console.error('봉사 데이터 불러오기 실패함');
28+
return;
29+
}
30+
if (data) {
31+
console.log('연동 성공! 데이터:', data);
32+
setHistories(data.volunteer_applications || []);
33+
}
34+
}, [data, isLoading, isError]);
2835

2936
return (
3037
<Wrapper>

0 commit comments

Comments
 (0)