react-code-dataset / wp-calypso /client /data /p2 /with-p2-hub-p2-count.js
Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
import { createHigherOrderComponent } from '@wordpress/compose';
import useP2HubP2sQuery from 'calypso/data/p2/use-p2-hub-p2s-query';
const withP2HubP2Count = createHigherOrderComponent(
( Wrapped ) => ( props ) => {
// Limit query to 1 since we are only interested in the totalItems count.
const { data } = useP2HubP2sQuery( props.siteId, { limit: 1 } );
return <Wrapped { ...props } p2HubP2Count={ data?.totalItems || 0 } />;
},
'withP2HubP2Count'
);
export default withP2HubP2Count;