@shopify/app-bridge-react
Version:
**[Join our team and work on libraries like this one.](https://www.shopify.ca/careers)**
56 lines (55 loc) • 2.08 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importDefault(require("react"));
var actions_1 = require("@shopify/app-bridge/actions");
var context_1 = require("../../context");
/**
* Loading component
*
* @remarks
* React component which wraps the Shopify App Bridge Loading action.
*
* @public
*/
var Loading = /** @class */ (function (_super) {
__extends(Loading, _super);
function Loading() {
return _super !== null && _super.apply(this, arguments) || this;
}
Loading.prototype.componentDidMount = function () {
var app = this.context;
this.loading = actions_1.Loading.create(app);
if (this.loading != null) {
this.loading.dispatch(actions_1.Loading.Action.START);
}
};
Loading.prototype.componentWillUnmount = function () {
if (this.loading != null) {
this.loading.dispatch(actions_1.Loading.Action.STOP);
}
};
Loading.prototype.render = function () {
return null;
};
Loading.contextType = context_1.AppBridgeContext;
return Loading;
}(react_1.default.Component));
exports.default = Loading;
;