-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
45 additions
and
40 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { useQueryClient, useMutation } from '@tanstack/react-query'; | ||
import Toast from '@/utils/notification'; | ||
import { PostCommentType } from '@/types/types'; | ||
import { postComment } from '@/service/board'; | ||
|
||
export default function usePostComment() { | ||
const queryClient = useQueryClient(); | ||
const { mutate, isLoading } = useMutation({ | ||
mutationFn: (postCommentData: PostCommentType) => | ||
postComment(postCommentData), | ||
onSuccess: () => { | ||
Toast.success('댓글이 성공적으로 업로드 되었습니다.'); | ||
return queryClient.invalidateQueries(['comment']); | ||
}, | ||
onError: () => { | ||
Toast.error('댓글을 업로드하지 못했습니다. 잠시후 다시 시도해주세요.🥲'); | ||
}, | ||
}); | ||
return { mutate, isLoading }; | ||
} |
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