UNPKG

zent

Version:

一套前端设计语言和基于React的实现

31 lines (30 loc) 846 B
import { __extends } from "tslib"; import { Component } from 'react'; var LazyMount = (function (_super) { __extends(LazyMount, _super); function LazyMount(props) { var _this = _super.call(this, props) || this; _this.state = { mounted: props.mount, }; return _this; } LazyMount.prototype.render = function () { var children = this.props.children; var mounted = this.state.mounted; return mounted ? children : null; }; LazyMount.getDerivedStateFromProps = function (props, state) { if (props.mount && !state.mounted) { return { mounted: true, }; } return null; }; LazyMount.defaultProps = { mount: false, }; return LazyMount; }(Component)); export default LazyMount;