Download wp-calypso/client/landing/stepper/hooks/use-countries.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 751 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/landing/stepper/hooks/use-countries.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/landing/stepper/hooks/use-countries.ts
-
curl -L -o use-countries.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/landing/stepper/hooks/use-countries.ts
751 Bytes
| import { useLocale } from '@automattic/i18n-utils'; | |
| import { useQuery, UseQueryResult, UseQueryOptions } from '@tanstack/react-query'; | |
| import wpcom from 'calypso/lib/wp'; | |
| type WooCountries = Record< string, string >; | |
| export function useCountries( | |
| queryOptions: Omit< UseQueryOptions< any, Error, WooCountries >, 'queryKey' > = {} | |
| ): UseQueryResult< WooCountries > { | |
| const localeSlug = useLocale(); | |
| return useQuery< any, Error, WooCountries >( { | |
| queryKey: [ 'countries', localeSlug ], | |
| queryFn: () => | |
| wpcom.req.get( '/woocommerce/countries/regions/', { | |
| apiNamespace: 'wpcom/v2', | |
| } ), | |
| staleTime: Infinity, | |
| refetchOnWindowFocus: false, | |
| refetchOnReconnect: false, | |
| ...queryOptions, | |
| meta: { | |
| ...queryOptions.meta, | |
| }, | |
| } ); | |
| } | |