diff --git a/libs/horizon/src/renderer/vnode/VNode.ts b/libs/horizon/src/renderer/vnode/VNode.ts index e5a848de..9c9fd8e2 100644 --- a/libs/horizon/src/renderer/vnode/VNode.ts +++ b/libs/horizon/src/renderer/vnode/VNode.ts @@ -25,17 +25,17 @@ export class VNode { suspensePromises: any = null; // suspense组件的promise列表 changeList: any = null; // DOM的变更列表 - effectList: any[] = []; // useEffect 的更新数组 + effectList: any[] | null = []; // useEffect 的更新数组 updates: any[] | null = null; // TreeRoot和ClassComponent使用的更新数组 - stateCallbacks: any[] = []; // 存放存在setState的第二个参数和HorizonDOM.render的第三个参数所在的node数组 + stateCallbacks: any[] | null = []; // 存放存在setState的第二个参数和HorizonDOM.render的第三个参数所在的node数组 isForceUpdate: boolean = false; // 是否使用强制更新 state: any = null; // ClassComponent和TreeRoot的状态 - hooks: Array> = []; // 保存hook + hooks: Array> | null = []; // 保存hook suspenseChildStatus: string = ''; // Suspense的Children是否显示 - depContexts: Array> = []; // FunctionComponent和ClassComponent对context的依赖列表 + depContexts: Array> | null = []; // FunctionComponent和ClassComponent对context的依赖列表 isDepContextChange: boolean = false; // context是否变更 - dirtyNodes: Array = []; // 需要改动的节点数组 + dirtyNodes: Array | null = []; // 需要改动的节点数组 shouldUpdate: boolean = false; childShouldUpdate: boolean = false; outerDom: any; @@ -65,7 +65,7 @@ export class VNode { clearChild: VNode | null = null; // one tree相关属性 isCreated: boolean = true; - oldHooks: Array> = []; // 保存上一次执行的hook + oldHooks: Array> | null = []; // 保存上一次执行的hook oldState: any = null; oldRef: RefType | ((handle: any) => void) | null = null; suspenseChildThrow = false; diff --git a/libs/horizon/src/renderer/vnode/VNodeUtils.ts b/libs/horizon/src/renderer/vnode/VNodeUtils.ts index dc38b93e..82ad3ec8 100644 --- a/libs/horizon/src/renderer/vnode/VNodeUtils.ts +++ b/libs/horizon/src/renderer/vnode/VNodeUtils.ts @@ -79,28 +79,24 @@ export function travelVNodeTree( export function clearVNode(vNode: VNode) { vNode.child = null; vNode.next = null; - vNode.depContexts = []; - vNode.dirtyNodes = []; + vNode.depContexts = null; + vNode.dirtyNodes = null; vNode.state = null; - vNode.hooks = []; - vNode.suspenseChildStatus = ''; + vNode.hooks = null; vNode.props = null; vNode.parent = null; vNode.suspensePromises = null; vNode.changeList = null; - vNode.effectList = []; + vNode.effectList = null; vNode.updates = null; vNode.realNode = null; vNode.oldProps = null; - vNode.oldHooks = []; + vNode.oldHooks = null; vNode.oldState = null; vNode.oldRef = null; - vNode.suspenseChildThrow = false; - vNode.oldSuspenseChildStatus = ''; vNode.oldChild = null; - vNode.path = []; vNode.toUpdateNodes = null; vNode.belongClassVNode = null;