react-data-center
Version:
``` npm install react-data-center --save ``` * react 数据中心模块解决数据统一各模块通信问题 * 支持安全渲染 ## 使用 * 主入口
26 lines • 724 B
JavaScript
export default function (Com,errfn) {
['render',
'componentWillMount',
'componentDidMount',
'componentWillReceiveProps',
'componentWillUpdate',
'componentDidUpdate',
'componentWillUnmount'
].forEach(function (name) {
const 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
}