Download wp-calypso/client/data/invites/use-get-invites-query.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 682 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/data/invites/use-get-invites-query.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/data/invites/use-get-invites-query.ts
-
curl -L -o use-get-invites-query.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/data/invites/use-get-invites-query.ts
682 Bytes
| import { useQuery } from '@tanstack/react-query'; | |
| import { useDispatch, useSelector } from 'calypso/state'; | |
| import { requestSiteInvites } from 'calypso/state/invites/actions'; | |
| import { isRequestingInvitesForSite } from 'calypso/state/invites/selectors'; | |
| const useGetInvitesQuery = ( siteId: number ) => { | |
| const dispatch = useDispatch(); | |
| const requestingInProgress = useSelector( ( state ) => | |
| isRequestingInvitesForSite( state, siteId ) | |
| ); | |
| return useQuery( { | |
| queryKey: [ 'invites', siteId ], | |
| queryFn: () => { | |
| if ( siteId && ! requestingInProgress ) { | |
| dispatch( requestSiteInvites( siteId ) ); | |
| } | |
| return null; | |
| }, | |
| } ); | |
| }; | |
| export default useGetInvitesQuery; | |