File size: 759 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import { useEffect } from 'react';
import { useDispatch, useSelector } from 'calypso/state';
import { requestJetpackScanHistory } from 'calypso/state/jetpack-scan/history/actions';
import isRequestingJetpackScanHistory from 'calypso/state/selectors/is-requesting-jetpack-scan-history';
interface Props {
siteId: number;
}
const QueryJetpackScanHistory = ( { siteId }: Props ) => {
const requestingJetpackScanHistory = useSelector( ( state ) =>
isRequestingJetpackScanHistory( state, siteId )
);
const dispatch = useDispatch();
useEffect( () => {
if ( requestingJetpackScanHistory ) {
return;
}
siteId && dispatch( requestJetpackScanHistory( siteId ) );
}, [ dispatch, siteId ] );
return null;
};
export default QueryJetpackScanHistory;
|