File tree Expand file tree Collapse file tree 2 files changed +22
-8
lines changed Expand file tree Collapse file tree 2 files changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -17,14 +17,21 @@ export const VolunteerApplication = () => {
17
17
initTheme . get ( 'theme' ) === 'dark' ? THEME . DARK : THEME . LIGHT ,
18
18
) ;
19
19
20
- const { data } = useGetVolunteer ( ) ;
20
+ const { data, isLoading , isError } = useGetVolunteer ( ) ;
21
21
22
22
const [ applications , setApplications ] = useState < any [ ] > ( [ ] ) ;
23
23
24
24
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 ] ) ;
28
35
29
36
const removeApplication = ( volunteerId : string ) => {
30
37
setApplications ( ( prevApplications ) =>
Original file line number Diff line number Diff line change @@ -19,12 +19,19 @@ export const VolunteerHistory = () => {
19
19
initTheme . get ( 'theme' ) === 'dark' ? THEME . DARK : THEME . LIGHT ,
20
20
) ;
21
21
22
- const { data } = useGetMyVolunteers ( ) ;
22
+ const { data, isLoading , isError } = useGetMyVolunteers ( ) ;
23
23
24
24
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 ] ) ;
28
35
29
36
return (
30
37
< Wrapper >
You can’t perform that action at this time.
0 commit comments