-
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
공통 컴포넌트 구현 (버튼, 진행 중인 미션 배너) (issue #94) #104
Conversation
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.
프룬 고생 많으셨어요~!
useSuspenseQuery
관련해서 코멘트 하나 남겨보았는데 확인해주시면 감사하겠습니다!
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
|
||
const useMissionInProgress = () => { | ||
const { data, isLoading, isError, isSuccess } = useSuspenseQuery<MissionInProgress>({ |
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.
이 useSuspenseQuery 자체를 리턴해주면 사용하는 컴포넌트 단에서 선택적으로 필요한 부분을 골라서 사용할수 있을거 같은데요!?
useSuspenseQuery
를 사용하면 자동으로 상위에서 감싸준 Suspense를 감지해서 isLoading
상태값 없이 선언적으로 표현해볼수 있을거 같아요 👍
const useMissionInProgress = () => {
return useSuspenseQuery< MissionInProgress >({
queryKey: ['inProgress'],
queryFn: getMissionInProgress,
});
};
- Component.tsx
export default function MyMissionInProgressBanner() {
const { data: missionInProgress, isSuccess } = useMissionInProgress();
위처럼 isSuccess나 isError 등등 필요한 값들만 꺼내와서 사용할수 있어서 조금 더 확장성이 있지 않을까 하는데 어떻게 생각하세요 !?
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.
오 이렇게 바로 작성하는 방법도 있군요! 감사합니다 버건디👍
구현 요약
연관 이슈
close #94
참고
코드 리뷰에
RCA 룰
을 적용할 시 참고해주세요.