mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-11 18:42:56 +00:00
fix: recover component lifecycle and avoid execute from scope __proto__
This commit is contained in:
parent
7c72261fef
commit
394b56d0ce
@ -50,6 +50,11 @@ export function executeLifeCycleMethod(context: any, schema: IPublicTypeNodeSche
|
||||
return;
|
||||
}
|
||||
|
||||
// avoid execute lifeCycle method from __proto__'s method (it is React class Component Class lifeCycle)
|
||||
if (!Object.prototype.hasOwnProperty.call(context, method) && method !== 'constructor') {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: cache
|
||||
if (isJSExpression(fn) || isJSFunction(fn)) {
|
||||
fn = thisRequiredInJSE ? parseThisRequiredExpression(fn, context) : parseExpression(fn, context);
|
||||
|
||||
@ -46,26 +46,5 @@ export default function componentRendererFactory(): IBaseRenderComponent {
|
||||
|
||||
return this.__renderComp(Component, this.__renderContextProvider({ compContext: this }));
|
||||
}
|
||||
|
||||
getComponentName() {
|
||||
return this.props?.componentName;
|
||||
}
|
||||
|
||||
/** 需要重载下面几个方法,如果在低代码组件中绑定了对应的生命周期时会出现死循环 */
|
||||
componentDidMount() {
|
||||
this.__debug(`componentDidMount - ${this.getComponentName()}`);
|
||||
}
|
||||
getSnapshotBeforeUpdate() {
|
||||
this.__debug(`getSnapshotBeforeUpdate - ${this.getComponentName()}`);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
this.__debug(`componentDidUpdate - ${this.getComponentName()}`);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
this.__debug(`componentWillUnmount - ${this.getComponentName()}`);
|
||||
}
|
||||
componentDidCatch() {
|
||||
this.__debug(`componentDidCatch - ${this.getComponentName()}`);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user