react-code-dataset / wp-calypso /client /components /data /query-jetpack-scan-threat-counts /index.jsx
react-code-dataset / wp-calypso /client /components /data /query-jetpack-scan-threat-counts /index.jsx
Download wp-calypso/client/components/data/query-jetpack-scan-threat-counts/index.jsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 876 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/components/data/query-jetpack-scan-threat-counts/index.jsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/components/data/query-jetpack-scan-threat-counts/index.jsx
-
curl -L -o index.jsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/components/data/query-jetpack-scan-threat-counts/index.jsx
876 Bytes
| import { useEffect, useState } from 'react'; | |
| import { useDispatch, useSelector } from 'react-redux'; | |
| import { requestThreatCounts } from 'calypso/state/jetpack-scan/threat-counts/actions'; | |
| import isRequestingJetpackScanThreatCounts from 'calypso/state/selectors/is-requesting-jetpack-scan-threat-counts'; | |
| const QueryJetpackScanThreatCounts = ( { siteId } ) => { | |
| const dispatch = useDispatch(); | |
| const [ requested, setRequested ] = useState( | |
| useSelector( ( state ) => isRequestingJetpackScanThreatCounts( state, siteId ) ) | |
| ); | |
| useEffect( () => { | |
| // Don't request if we're missing a siteId, | |
| // or if a request is already in progress | |
| if ( ! siteId || requested ) { | |
| return; | |
| } | |
| dispatch( requestThreatCounts( siteId ) ); | |
| setRequested( true ); | |
| }, [ siteId, requested, dispatch, setRequested ] ); | |
| return null; | |
| }; | |
| export default QueryJetpackScanThreatCounts; | |