Skip to content

Instantly share code, notes, and snippets.

@huynhducduy
Last active July 8, 2025 05:39
Show Gist options
  • Save huynhducduy/1decb988ba6904cc11abacdf4748de6a to your computer and use it in GitHub Desktop.
Save huynhducduy/1decb988ba6904cc11abacdf4748de6a to your computer and use it in GitHub Desktop.
import type {UseQueryOptions} from '@tanstack/react-query'
export function getDepositWithdrawalHistoryQueryKey(params: {
page: number
limit: number
}) {
return [
'deposit-withdrawal-history',
params.page,
params.limit,
] as const
}
export function getDepositWithdrawalHistoryQueryOptions<
TData = DepositWithdrawalHistoryData,
TError = Error,
>(
params: {
page: number
limit: number
},
options?: Omit<
UseQueryOptions<DepositWithdrawalHistoryData, TError, TData>,
'queryKey' | 'queryFn'
>,
) {
return queryOptions({
queryKey: getDepositWithdrawalHistoryQueryKey(params),
queryFn: async () =>
fetchDepositWithdrawalHistories(
params.page,
params.limit,
),
refetchInterval: 10000,
...options,
})
}
export default function useDepositWithdrawalHistoryQuery(
page: number,
limit: number,
) {
return useQuery(
getDepositWithdrawalHistoryQueryOptions({
page,
limit,
}),
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment