Skip to content
Snippets Groups Projects
Commit 049f8e50 authored by Lukas's avatar Lukas
Browse files

Create custom hook for post comments

parent 5f0d08ca
No related branches found
No related tags found
1 merge request!510Lbudginas/#411 add post comments
import { useQuery } from "@tanstack/react-query";
import fetchingService from "@/services/FetchingService";
const usePostContentReplies = (accountName: string, permlink: string) => {
const trimAccount = accountName.replace("@", "");
const { data, isLoading, isError } = useQuery({
queryKey: ["post content replies", trimAccount, permlink],
queryFn: () => fetchPostContentReplies(trimAccount, permlink),
refetchOnWindowFocus: false,
});
const fetchPostContentReplies = async (
accountName: string,
permlink: string
) => {
if (!accountName || !permlink) return null;
const response = await fetchingService.getContentReplies(
accountName,
permlink
);
return response;
};
return { data, isLoading, isError };
};
export default usePostContentReplies;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment