UNPKG

@shopify/react-async

Version:

Tools for creating powerful, asynchronously-loaded React components

16 lines (13 loc) 484 B
import React from 'react'; import { extract } from '@shopify/react-effect/server'; import { AsyncAssetManager, AsyncAssetContext } from './context/assets.mjs'; async function getUsedAssets(element, ...args) { const asyncAssets = new AsyncAssetManager(); await extract(element, { decorate: element => /*#__PURE__*/React.createElement(AsyncAssetContext.Provider, { value: asyncAssets }, element) }); return asyncAssets.used(...args); } export { getUsedAssets };