Commit b3c5e622 by G

custom hook for transaction history

parent 52c5bb3b
import { type Transaction, getTransactionsHistory } from "@/utils/requests/transactions";
import { LOG } from "@logger";
import { useQuery } from "@tanstack/react-query";
import { useMemo } from "react";
const log = LOG.extend("useTransactionsHistory");
const useTransactionsHistory = () => {
log.verbose("useTransactionsHistory");
const { data, isLoading, error, refetch } = useQuery({
queryKey: ["transactionsHistory"],
queryFn: getTransactionsHistory,
});
const transactionsHistory: Transaction[] = useMemo(() => data || [], [data]);
return {
transactionsHistory,
isLoading,
error,
refetch,
};
};
export default useTransactionsHistory;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment