From 55dac3b56baa13b8b66de746d2af5a2bd3b5c065 Mon Sep 17 00:00:00 2001 From: * <8> Date: Mon, 21 Mar 2022 17:50:18 +0800 Subject: [PATCH] Match-id-580af01343fa5bba627a04ab667a638ec280a603 --- libs/horizon/src/renderer/components/BaseClassComponent.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/horizon/src/renderer/components/BaseClassComponent.ts b/libs/horizon/src/renderer/components/BaseClassComponent.ts index 74f6df80..b5b202c2 100644 --- a/libs/horizon/src/renderer/components/BaseClassComponent.ts +++ b/libs/horizon/src/renderer/components/BaseClassComponent.ts @@ -1,18 +1,22 @@ /** * Component的api setState和forceUpdate在实例生成阶段实现 */ + class Component { props: P; context: C; state: S | null; refs: any; - setState: any; forceUpdate: any; constructor(props: P, context: C) { this.props = props; this.context = context; } + + setState(state: S) { + console.error('Cant not call `this.setState` in the constructor of class component, it will do nothing') + } } // 兼容三方件 react-lifecycles-compat,它会读取 isReactComponent 属性值,不添加会导致 eview-ui 官网白屏