Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { useMutation, useQueryClient } from '@tanstack/react-query';
import { API } from '@/api';
import { AddFollowParams } from '@/types/service/follow';
export const useAddFollowers = (
{ userId }: { userId: number },
options?: { enabled?: boolean },
) => {
const queryClient = useQueryClient();
const query = useMutation({
mutationFn: (params: AddFollowParams) => API.followerService.addFollower(params),
...options,
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['followers', userId] });
console.log('팔로워 추가 성공');
},
onError: () => {
console.log('팔로워 추가 실패');
},
});
return query;
};
|