react-data-center
Version:
``` npm install react-data-center --save ``` * react 数据中心模块解决数据统一各模块通信问题 * 支持安全渲染 ## 使用 * 主入口
25 lines (23 loc) • 749 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = function (Com, errfn) {
['render', 'componentWillMount', 'componentDidMount', 'componentWillReceiveProps', 'componentWillUpdate', 'componentDidUpdate', 'componentWillUnmount'].forEach(function (name) {
var oFn = Com.prototype[name];
if (oFn) {
Com.prototype[name] = function () {
try {
return oFn.apply(this, arguments);
} catch (e) {
if (errfn) {
errfn(e);
} else {
console.error(e);
}
}
};
}
});
return Com;
};