react-code-dataset / wp-calypso /packages /data-stores /src /reader /queries /use-subscriptions-count-query.ts
react-code-dataset / wp-calypso /packages /data-stores /src /reader /queries /use-subscriptions-count-query.ts
Download wp-calypso/packages/data-stores/src/reader/queries/use-subscriptions-count-query.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 847 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/data-stores/src/reader/queries/use-subscriptions-count-query.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/packages/data-stores/src/reader/queries/use-subscriptions-count-query.ts
-
curl -L -o use-subscriptions-count-query.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/data-stores/src/reader/queries/use-subscriptions-count-query.ts
847 Bytes
| import { useQuery } from '@tanstack/react-query'; | |
| import { callApi } from '../helpers'; | |
| import { useCacheKey, useIsLoggedIn, useIsQueryEnabled } from '../hooks'; | |
| import type { SubscriptionManagerSubscriptionsCount } from '../types'; | |
| export const subscriptionsCountQueryKeyPrefix = [ 'read', 'subscriptions-count' ]; | |
| const useSubscriptionsCountQuery = () => { | |
| const { isLoggedIn } = useIsLoggedIn(); | |
| const enabled = useIsQueryEnabled(); | |
| const cacheKey = useCacheKey( subscriptionsCountQueryKeyPrefix ); | |
| return useQuery< SubscriptionManagerSubscriptionsCount >( { | |
| queryKey: cacheKey, | |
| queryFn: async () => { | |
| return await callApi< SubscriptionManagerSubscriptionsCount >( { | |
| path: '/read/subscriptions-count', | |
| isLoggedIn, | |
| } ); | |
| }, | |
| enabled, | |
| refetchOnWindowFocus: false, | |
| } ); | |
| }; | |
| export default useSubscriptionsCountQuery; | |