Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
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;
}