Download wp-calypso/client/components/data/query-jetpack-sites-features/index.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 911 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/components/data/query-jetpack-sites-features/index.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/components/data/query-jetpack-sites-features/index.tsx
-
curl -L -o index.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/components/data/query-jetpack-sites-features/index.tsx
911 Bytes
| import { useEffect } from 'react'; | |
| import { useDispatch } from 'calypso/state'; | |
| import { fetchJetpackSitesFeatures } from 'calypso/state/sites/features/actions'; | |
| import isRequestingJetpackSitesFeatures from 'calypso/state/sites/selectors/is-requesting-jetpack-sites-features'; | |
| const requestFeatures = () => ( dispatch: any, getState: any ) => { | |
| if ( ! isRequestingJetpackSitesFeatures( getState() ) ) { | |
| dispatch( fetchJetpackSitesFeatures() ); | |
| } | |
| }; | |
| /** | |
| * Makes an API request to fetch all features on all Jetpack sites for the current user. | |
| * This is the same data as QuerySiteFeatures, but this retrieves it for all Jetpack sites in | |
| * a single request whereas QuerySiteFeatures would have to make one request per site. | |
| */ | |
| export default function QueryJetpackSitesFeatures() { | |
| const dispatch = useDispatch(); | |
| useEffect( () => { | |
| dispatch( requestFeatures() ); | |
| }, [ dispatch ] ); | |
| return null; | |
| } | |