How to use the @shopify/react-async.useAsyncAsset function in @shopify/react-async

To help you get started, we’ve selected a few @shopify/react-async examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Shopify / quilt / packages / react-graphql / src / hooks / graphql-document.ts View on Github external
if (mounted.current) {
          setDocument(resolved);
        }
      } catch (error) {
        throw Error('error loading GraphQL document');
      }
    }
  }, [documentOrAsyncDocument, mounted]);

  useEffect(() => {
    if (!document) {
      loadDocument();
    }
  }, [document, loadDocument]);

  useAsyncAsset(
    isDocumentNode(documentOrAsyncDocument)
      ? undefined
      : documentOrAsyncDocument.resolver.id,
  );

  return document;
}

@shopify/react-async

Tools for creating powerful, asynchronously-loaded React components

MIT
Latest version published 6 days ago

Package Health Score

93 / 100
Full package analysis

Similar packages