shineout
Version:
Shein 前端组件库
38 lines (29 loc) • 1.14 kB
JavaScript
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React from 'react';
import { noti } from '../config';
export default (function (Com, name) {
var _temp;
return _temp =
/*#__PURE__*/
function (_React$Component) {
_inheritsLoose(_temp, _React$Component);
function _temp(props) {
var _this;
_this = _React$Component.call(this, props) || this;
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleUpdate", void 0);
_this.handleUpdate = _this.forceUpdate.bind(_assertThisInitialized(_assertThisInitialized(_this)));
noti.subscribe(name, _this.handleUpdate);
return _this;
}
var _proto = _temp.prototype;
_proto.componentWillUnmount = function componentWillUnmount() {
noti.unsubscribe(name, this.handleUpdate);
};
_proto.render = function render() {
return React.createElement(Com, this.props);
};
return _temp;
}(React.Component), _temp;
});