Skip to content

Commit

Permalink
feat: (#168) 게시글 상세 조회 커스텀 쿼리 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
inyeong-kang committed Aug 3, 2023
1 parent 416546d commit 8067960
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions frontend/src/hooks/query/post/usePostDetail.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { useQuery } from '@tanstack/react-query';

import { PostInfo } from '@type/post';

import { getPost } from '@api/post';

import { QUERY_KEY } from '@constants/queryKey';

export const usePostDetail = (postId: number) => {
const { data, error, isLoading } = useQuery<PostInfo>(
[QUERY_KEY.POST_DETAIL, postId],
() => getPost(postId),
{
onSuccess: data => {
return data;
},
onError: error => {
window.console.error(error);
},
}
);

return { data, error, isLoading };
};

0 comments on commit 8067960

Please sign in to comment.