Skip to content

Commit 394b56d

Browse files
1ncounterliujuping
authored andcommitted
fix: recover component lifecycle and avoid execute from scope __proto__
1 parent 7c72261 commit 394b56d

2 files changed

Lines changed: 5 additions & 21 deletions

File tree

packages/renderer-core/src/renderer/base.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ export function executeLifeCycleMethod(context: any, schema: IPublicTypeNodeSche
5050
return;
5151
}
5252

53+
// avoid execute lifeCycle method from __proto__'s method (it is React class Component Class lifeCycle)
54+
if (!Object.prototype.hasOwnProperty.call(context, method) && method !== 'constructor') {
55+
return;
56+
}
57+
5358
// TODO: cache
5459
if (isJSExpression(fn) || isJSFunction(fn)) {
5560
fn = thisRequiredInJSE ? parseThisRequiredExpression(fn, context) : parseExpression(fn, context);

packages/renderer-core/src/renderer/component.tsx

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,5 @@ export default function componentRendererFactory(): IBaseRenderComponent {
4646

4747
return this.__renderComp(Component, this.__renderContextProvider({ compContext: this }));
4848
}
49-
50-
getComponentName() {
51-
return this.props?.componentName;
52-
}
53-
54-
/** 需要重载下面几个方法,如果在低代码组件中绑定了对应的生命周期时会出现死循环 */
55-
componentDidMount() {
56-
this.__debug(`componentDidMount - ${this.getComponentName()}`);
57-
}
58-
getSnapshotBeforeUpdate() {
59-
this.__debug(`getSnapshotBeforeUpdate - ${this.getComponentName()}`);
60-
}
61-
componentDidUpdate() {
62-
this.__debug(`componentDidUpdate - ${this.getComponentName()}`);
63-
}
64-
componentWillUnmount() {
65-
this.__debug(`componentWillUnmount - ${this.getComponentName()}`);
66-
}
67-
componentDidCatch() {
68-
this.__debug(`componentDidCatch - ${this.getComponentName()}`);
69-
}
7049
};
7150
}

0 commit comments

Comments
 (0)