How to use the @shopify/app-bridge/actions.Loading.create function in @shopify/app-bridge

To help you get started, we’ve selected a few @shopify/app-bridge 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 / polaris-react / src / components / Loading / Loading.tsx View on Github external
useEffect(() => {
    if (appBridge == null) {
      startLoading();
    } else {
      // eslint-disable-next-line no-console
      console.warn(
        'Deprecation: Using `Loading` in an embedded app is deprecated and will be removed in v5.0. Use `Loading` from `@shopify/app-bridge-react` instead: https://help.shopify.com/en/api/embedded-apps/app-bridge/react-components/loading',
      );

      appBridgeLoading.current = AppBridgeLoading.create(appBridge);
      appBridgeLoading.current.dispatch(AppBridgeLoading.Action.START);
    }

    return () => {
      if (appBridge == null) {
        stopLoading();
      } else {
        appBridgeLoading.current &&
          appBridgeLoading.current.dispatch(AppBridgeLoading.Action.STOP);
      }
    };
  }, [appBridge, startLoading, stopLoading]);