react-show-data
Version:
A light-weight react toast component built for mobile web app
43 lines (42 loc) • 1.85 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 });
var React = require("react");
var default_1 = (function (_super) {
__extends(default_1, _super);
function default_1() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.state = {
isShow: false
};
return _this;
}
default_1.prototype.componentDidMount = function () {
this.props.isShow !== void 0 &&
this.setState({ isShow: this.props.isShow });
};
default_1.prototype.render = function () {
var _this = this;
var _a = this.props, data = _a.data, _b = _a.isFix, isFix = _b === void 0 ? true : _b;
var isShow = this.state.isShow;
return (React.createElement("div", { style: isFix
? { position: "fixed", top: 50, right: 50, width: 300 }
: { display: "inline-block" } },
React.createElement("button", { onClick: function () { return _this.setState({ isShow: !isShow }); } }, isShow ? "隐藏" : "显示"),
React.createElement("div", { style: { display: isShow ? "block" : "none" } }, JSON.stringify(data))));
};
return default_1;
}(React.Component));
exports.default = default_1;