-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* refactor: comments 쿼리를 쿼리 옵션 기반으로 리팩토링 * refactor: songDetailEntries 쿼리를 쿼리 옵션 기반으로 리팩토링 * refactor: extraPrevSongDetails, extraNextSongDetails 인피니트 쿼리를 쿼리 옵션 기반으로 리팩토링 * refactor: mutate 옵션이 드러나도록 컴포넌트에서 직접 사용하도록 변경 * feat: 프로젝트 내 useMutation 훅 depreacted 처리
- Loading branch information
1 parent
ed0666b
commit ded29ab
Showing
7 changed files
with
49 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,8 @@ | ||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; | ||
import { getComments, postComment } from '../remotes/comments'; | ||
import { queryOptions } from '@tanstack/react-query'; | ||
import { getComments } from '../remotes/comments'; | ||
|
||
export const useCommentsQuery = (songId: number, partId: number) => { | ||
const { data: comments, ...queries } = useQuery({ | ||
export const commentsQueryOptions = (songId: number, partId: number) => | ||
queryOptions({ | ||
queryKey: ['comments', songId, partId], | ||
queryFn: () => getComments(songId, partId), | ||
}); | ||
|
||
return { comments, queries }; | ||
}; | ||
|
||
export const usePostCommentMutation = () => { | ||
const client = useQueryClient(); | ||
|
||
const { mutate: postNewComment, ...mutations } = useMutation({ | ||
mutationFn: postComment, | ||
onSuccess: (_, { songId, partId }) => { | ||
client.invalidateQueries({ queryKey: ['comments', songId, partId] }); | ||
}, | ||
}); | ||
|
||
return { postNewComment, mutations }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters