diff --git a/src/apis/chatRoom/useSocialData.tsx b/src/apis/chatRoom/useSocialData.tsx index 5282461..3d45bab 100644 --- a/src/apis/chatRoom/useSocialData.tsx +++ b/src/apis/chatRoom/useSocialData.tsx @@ -1,16 +1,17 @@ import { useSuspenseQueries } from '@tanstack/react-query' import { fetchChatRoomList } from '~apis/chatRoom/fetchChatRoomList' import { fetchFriendList } from '~apis/friend/fetchFriendList' +import { queryKey } from '~constants/queryKey' export function useSocialData() { const results = useSuspenseQueries({ queries: [ { - queryKey: ['chatRoomList'], + queryKey: queryKey.social.chatRoomList(), queryFn: () => fetchChatRoomList().then(res => res.data), }, { - queryKey: ['friendList'], + queryKey: queryKey.social.friendList(), queryFn: () => fetchFriendList().then(res => res.data), }, ], diff --git a/src/apis/member/useFetchProfile.tsx b/src/apis/member/useFetchProfile.tsx index 5796498..9d7a80e 100644 --- a/src/apis/member/useFetchProfile.tsx +++ b/src/apis/member/useFetchProfile.tsx @@ -1,9 +1,10 @@ import { useSuspenseQuery, UseSuspenseQueryResult } from '@tanstack/react-query' import { fetchProfile, FetchProfileResponse } from '~apis/member/fetchProfile' +import { queryKey } from '~constants/queryKey' export const useFetchProfile = (memberId: number): UseSuspenseQueryResult => { return useSuspenseQuery({ - queryKey: ['profile', memberId], + queryKey: queryKey.profile(memberId), queryFn: () => fetchProfile({ memberId }).then(data => data.data), staleTime: 1000 * 60 * 5, // 5분 }) diff --git a/src/constants/queryKey.ts b/src/constants/queryKey.ts new file mode 100644 index 0000000..3a216be --- /dev/null +++ b/src/constants/queryKey.ts @@ -0,0 +1,7 @@ +export const queryKey = { + social: { + chatRoomList: () => ['chatRoomList'], + friendList: () => ['friendList'], + }, + profile: (memberId: number) => ['profile', memberId], +} diff --git a/src/pages/ProfilePage/index.tsx b/src/pages/ProfilePage/index.tsx index 7ab7656..c23d87a 100644 --- a/src/pages/ProfilePage/index.tsx +++ b/src/pages/ProfilePage/index.tsx @@ -16,6 +16,7 @@ import * as S from './styles' function ProfileContent({ id }: { id: number }) { const { data } = useFetchProfile(+id) const navigate = useNavigate() + return (