-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: useSuspenseQuery 적용 및 훅 리팩터링 #326
The head ref may contain hidden characters: "refactor/325-usesuspensequery_\uD6C5_\uB9AC\uD329\uD130\uB9C1"
Changes from 11 commits
f924b2c
a6c3f90
8e6afec
73dd26c
c8a1ded
c61f37c
2572b5e
17840da
babd691
a18a1ff
9178bb4
51afb42
e783b2f
bfd869c
9ef1b95
63242ff
793f0b1
2be5192
cc9b034
ec196cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { | ||
DayArea, | ||
DayHeader, | ||
SkeletonItem, | ||
SkeletonItemContent, | ||
TimelineArea, | ||
YearHeader, | ||
} from './Timeline.style'; | ||
|
||
interface SkeletonProps { | ||
hasYearHeader?: boolean; | ||
} | ||
|
||
const Skeleton = ({ hasYearHeader }: SkeletonProps) => ( | ||
<> | ||
{hasYearHeader && <YearHeader />} | ||
{Array(10) | ||
.fill(null) | ||
.map((_, index) => ( | ||
<DayArea key={index}> | ||
<DayHeader /> | ||
<TimelineArea> | ||
<SkeletonItem> | ||
<SkeletonItemContent /> | ||
</SkeletonItem> | ||
</TimelineArea> | ||
</DayArea> | ||
))} | ||
</> | ||
); | ||
|
||
export default Skeleton; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { ReminderExtendType } from 'types/reminder'; | ||
import type { ReminderExtendType } from 'types/reminder'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
import { MonthReminderBox, MonthTitle } from './MonthBox.style'; | ||
import CardBox from '../CardBox'; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
import AuthAPI from 'apis/auth'; | ||
import throwOnInvalidStatus from 'utils/throwOnInvalidStatus'; | ||
|
||
const useLogin = (code: string) => { | ||
return useQuery<null, Error, void>({ | ||
const useLogin = (code: string) => | ||
useSuspenseQuery<null, Error, void>({ | ||
queryKey: ['getSession', code], | ||
queryFn: async () => { | ||
const response = await AuthAPI.getSessionId(code); | ||
|
||
throwOnInvalidStatus(response); | ||
|
||
return null; | ||
}, | ||
suspense: true, | ||
}); | ||
}; | ||
|
||
export default useLogin; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ import throwOnInvalidStatus from 'utils/throwOnInvalidStatus'; | |
import useCheckSessionId from '../auth/useCheckSessionId'; | ||
|
||
const useYearList = (petPlantId: PetPlantDetails['id'], filter: HistoryType[] = []) => { | ||
const { isSuccess } = useCheckSessionId(); | ||
useCheckSessionId(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. R
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 훅에서는 useCheckSessionId가 없어도 될 것 같네요! |
||
|
||
return useInfiniteQuery< | ||
HistoryResponse, | ||
|
@@ -32,7 +32,7 @@ const useYearList = (petPlantId: PetPlantDetails['id'], filter: HistoryType[] = | |
return data; | ||
}, | ||
|
||
defaultPageParam: 0, | ||
initialPageParam: 0, | ||
getNextPageParam: ({ hasNext }, _allPages, lastPageParam) => { | ||
return hasNext ? lastPageParam + 1 : undefined; | ||
}, | ||
|
@@ -45,7 +45,6 @@ const useYearList = (petPlantId: PetPlantDetails['id'], filter: HistoryType[] = | |
}, | ||
|
||
retry: noRetryIfUnauthorized, | ||
enabled: isSuccess, | ||
refetchOnWindowFocus: false, | ||
placeholderData: keepPreviousData, | ||
gcTime: 0, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C
Calendar > useCalendar
보다 hooks 폴더로 감싸고 넣는것은 어떻게 생각하시나요?Calendar > hooks > useCalendar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋습니다!