PATH:
home
/
letacommog
/
newrdv1
/
wp-content
/
plugins1
/
woocommerce
/
packages
/
woocommerce-blocks
/
assets
/
js
/
hocs
/** * External dependencies */ import { useRef } from '@wordpress/element'; import { getSetting } from '@woocommerce/settings'; import { SCHEMA_STORE_KEY } from '@woocommerce/block-data'; import { useSelect } from '@wordpress/data'; /** * Hydrate Rest API data from settings to reduce the number of API requests needed. */ const useRestApiHydration = () => { const restApiRoutes = useRef( getSetting( 'restApiRoutes' ) ); useSelect( ( select, registry ) => { if ( ! restApiRoutes.current ) { return; } const { isResolving, hasFinishedResolution } = select( SCHEMA_STORE_KEY ); const { receiveRoutes, startResolution, finishResolution, } = registry.dispatch( SCHEMA_STORE_KEY ); Object.keys( restApiRoutes.current ).forEach( ( namespace ) => { const routes = restApiRoutes.current[ namespace ]; if ( ! isResolving( 'getRoutes', [ namespace ] ) && ! hasFinishedResolution( 'getRoutes', [ namespace ] ) ) { startResolution( 'getRoutes', [ namespace ] ); receiveRoutes( routes, [ namespace ] ); finishResolution( 'getRoutes', [ namespace ] ); } } ); }, [] ); }; /** * HOC that calls the useRestApiHydration hook. */ const withRestApiHydration = ( OriginalComponent ) => { return ( props ) => { useRestApiHydration(); return <OriginalComponent { ...props } />; }; }; export default withRestApiHydration;
[+]
..
[-] with-categories.js
[edit]
[-] with-transform-single-select-to-multiple-select.js
[edit]
[+]
test
[-] with-searched-products.js
[edit]
[-] index.js
[edit]
[-] with-rest-api-hydration.js
[edit]
[-] with-product.js
[edit]
[-] with-attributes.js
[edit]
[-] with-product-variations.js
[edit]
[-] with-category.js
[edit]