react-kjua
Version:
React component to generate a kjua QR Code
45 lines (44 loc) • 1.5 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 (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Kjua = void 0;
var React = require("react");
var kjua = require("kjua");
var Kjua = /** @class */ (function (_super) {
__extends(Kjua, _super);
function Kjua(props) {
var _this = _super.call(this, props) || this;
_this.el = React.createRef();
return _this;
}
Kjua.prototype.componentDidMount = function () {
this.update();
};
Kjua.prototype.componentDidUpdate = function () {
this.el.current.removeChild(this.qr);
this.update();
};
Kjua.prototype.update = function () {
this.qr = kjua(this.props);
this.el.current.appendChild(this.qr);
};
Kjua.prototype.render = function () {
return React.createElement('div', {
ref: this.el
});
};
return Kjua;
}(React.PureComponent));
exports.Kjua = Kjua;