import { useMutation, useQueryClient } from "@tanstack/react-query"; import { postGweet } from "../api/post-gweet"; export const useCreateGweet = () => { const queryClient = useQueryClient(); return useMutation( ({ content, files, userId, replyToGweetId, quoteGweetId, }: { content: string; files: File[]; userId: string; replyToGweetId?: string | null; quoteGweetId?: string | null; }) => { return postGweet({ content, files, userId, replyToGweetId, quoteGweetId, }); }, { onSuccess: () => { queryClient.invalidateQueries(["gweets"]); queryClient.invalidateQueries(["hashtags"]); }, onError: (error) => { console.log("error", error); }, }, ); };