Download wp-calypso/packages/data-stores/src/templates/use-template.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 716 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/data-stores/src/templates/use-template.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/packages/data-stores/src/templates/use-template.ts
-
curl -L -o use-template.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/data-stores/src/templates/use-template.ts
716 Bytes
| import { useQuery, UseQueryResult, QueryOptions } from '@tanstack/react-query'; | |
| import wpcomRequest from 'wpcom-proxy-request'; | |
| import type { Template } from './types'; | |
| interface Options extends QueryOptions< Template > { | |
| enabled?: boolean; | |
| } | |
| const useTemplate = ( | |
| siteId: string | number, | |
| templateId: string, | |
| queryOptions: Omit< Options, 'queryKey' > = {} | |
| ): UseQueryResult< Template > => { | |
| return useQuery< Template >( { | |
| queryKey: [ siteId, 'templates', templateId ], | |
| queryFn: () => | |
| wpcomRequest( { | |
| path: `/sites/${ siteId }/templates/${ templateId }`, | |
| apiNamespace: 'wp/v2', | |
| } ), | |
| refetchOnMount: 'always', | |
| staleTime: Infinity, | |
| ...queryOptions, | |
| } ); | |
| }; | |
| export default useTemplate; | |