4주차 월요일 미팅 #108
KingNono1030
started this conversation in
회의록
4주차 월요일 미팅
#108
Replies: 1 comment 1 reply
-
query 문 예시 코드/**
* 그룹 데이터를 가져오는 함수
* @param groupId - 가져올 그룹의 ID
* @returns 그룹 데이터
*/
export const getGroups = (groupId: string) => {
return authAxiosInstance.get<GroupResponse>(`groups/${groupId}`);
};
/**
* @useGroupsQuery
* 주어진 그룹 ID로 서버에서 그룹 데이터를 가져오는 훅입니다.
* @param id - 그룹 ID
* @returns 그룹 데이터와 로딩/에러 상태
*/
/**
* 상세 설명:
*
* 1. **queryKey**:
* - 캐시를 구분하기 위한 고유 키
* - `['groups', id]`로 설정하여 그룹 ID별로 데이터를 캐싱하고 분리
* - 동일한 `id`로 여러 번 호출 시, 동일한 데이터를 캐시에서 빠르게 가져올 수 있음
*
* 2. **queryFn**:
* - 데이터를 가져오는 비동기 함수. `fetchGroup` 함수를 호출하여 해당 `id`에 대한 그룹 정보를 서버에서 가져옴
* - 이 함수는 React Query가 내부적으로 데이터를 요청할 때 호출
*
* 3. **staleTime**:
* - 5분이 지나기 전에는 캐시된 데이터를 그대로 사용하며, 이후에는 자동으로 새로운 데이터를 서버에서 요청
*
* 4. **retry**:
* - 데이터 요청이 실패했을 경우 재시도 횟수를 의미
*/
export const useGroupsQuery = (id: string) => {
return useQuery({
queryKey: ['groups', id],
queryFn: () => getGroups(id),
staleTime: queryOptions.staleTime,
gcTime: queryOptions.gcTime,
retry: 1,
});
}; |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
팀 미팅 기록
체크박스 관련
AuthState 타입 관리 위치
env 관련 이슈
api 관련 디렉토리 구조
with credentails
axios vs ky
api routes
1. Zustand의 persist로 인증 상태 관리
작동 방식
장점
단점 (보안 상 치명적)
2. HttpOnly 쿠키를 사용한 토큰 관리
작동 방식
장점
단점
Beta Was this translation helpful? Give feedback.
All reactions