Skip to content

Commit

Permalink
Merge pull request #201 from Step3-kakao-tech-campus/feat/#171
Browse files Browse the repository at this point in the history
보호소에서 데이터 못 불러오는 문제 해결
  • Loading branch information
hjiwon authored Nov 11, 2023
2 parents 819d8a3 + a72898d commit 430c34e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/commons/modals/CategoryModal.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { useRecoilState } from 'recoil';
import regionState, { RegionType } from 'recoil/regionState';
import speciesState, { SpeciesType } from 'recoil/speciesState';
Expand Down
6 changes: 5 additions & 1 deletion src/pages/shelterInfo/ShelterInfoPage.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { Suspense } from 'react';
import ErrorBoundary from 'layouts/ErrorBoundary';
import ShelterInfo from './components/ShelterInfo';
import ShelterInfoSkeleton from './components/ShelterInfoSkeleton';

const ShelterInfoPage = () => {
return (
<ErrorBoundary>
<ShelterInfo />
<Suspense fallback={<ShelterInfoSkeleton />}>
<ShelterInfo />
</Suspense>
</ErrorBoundary>
);
};
Expand Down
7 changes: 2 additions & 5 deletions src/pages/shelterInfo/components/ShelterInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useEffect, useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import useFetch from 'commons/apis/useFetch';
import VShelterInfo from './VShelterInfo';
import ShelterInfoSkeleton from './ShelterInfoSkeleton';
import { ShelterInfoPageProps } from '../shelterInfoType';

const ShelterInfo = () => {
Expand All @@ -17,6 +16,8 @@ const ShelterInfo = () => {
const { data, isLoading, isError } = useQuery({
queryKey: ['page', currentPage],
queryFn: () => useFetch(`/shelter/${shelterId}?page=${currentPage}`),
suspense: true,
refetchOnMount: true,
});

useEffect(() => {
Expand Down Expand Up @@ -49,10 +50,6 @@ const ShelterInfo = () => {
}
}, [data, isLoading, isError]);

if (isLoading) {
return <ShelterInfoSkeleton />;
}

if (isError) {
return <div>Error: {isError}</div>;
}
Expand Down

0 comments on commit 430c34e

Please sign in to comment.