react-code-dataset / wp-calypso /client /components /data /query-jetpack-user-licenses-counts /index.ts
react-code-dataset / wp-calypso /client /components /data /query-jetpack-user-licenses-counts /index.ts
Download wp-calypso/client/components/data/query-jetpack-user-licenses-counts/index.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 897 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/components/data/query-jetpack-user-licenses-counts/index.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/components/data/query-jetpack-user-licenses-counts/index.ts
-
curl -L -o index.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/components/data/query-jetpack-user-licenses-counts/index.ts
897 Bytes
| import { useEffect } from 'react'; | |
| import { useDispatch, useSelector } from 'calypso/state'; | |
| import { requestLicensesCounts } from 'calypso/state/user-licensing/actions'; | |
| import { isFetchingUserLicensesCounts } from 'calypso/state/user-licensing/selectors'; | |
| export default function QueryJetpackUserLicenses(): null { | |
| const dispatch = useDispatch(); | |
| const currentlyFetchingUserLicensesCounts = useSelector( isFetchingUserLicensesCounts ); | |
| useEffect( | |
| () => { | |
| if ( ! currentlyFetchingUserLicensesCounts ) { | |
| dispatch( requestLicensesCounts() ); | |
| } | |
| }, | |
| // `currentlyFetchingUserLicensesCounts` is technically a dependency, but we exclude it here; | |
| // otherwise, it would re-run the effect once the request completes, | |
| // causing another request to be sent, starting an infinite loop. | |
| /* eslint-disable-next-line react-hooks/exhaustive-deps */ | |
| [ dispatch ] | |
| ); | |
| return null; | |
| } | |