diff --git a/libs/horizon/src/renderer/vnode/VNode.ts b/libs/horizon/src/renderer/vnode/VNode.ts index 371e488d..a48c4ab9 100644 --- a/libs/horizon/src/renderer/vnode/VNode.ts +++ b/libs/horizon/src/renderer/vnode/VNode.ts @@ -137,6 +137,7 @@ export class VNode { this.realNode = null; this.stateCallbacks = null; this.isLazyComponent = true; + this.lazyType = null; break; case Fragment: break; diff --git a/libs/horizon/src/renderer/vnode/VNodeCreator.ts b/libs/horizon/src/renderer/vnode/VNodeCreator.ts index c8832fa8..b37fa3c7 100644 --- a/libs/horizon/src/renderer/vnode/VNodeCreator.ts +++ b/libs/horizon/src/renderer/vnode/VNodeCreator.ts @@ -84,28 +84,6 @@ export function updateVNode(vNode: VNode, vNodeProps?: any): VNode { return vNode; } -function getVNodeTag(type: any) { - let vNodeTag = ClsOrFunComponent; - let isLazy = false; - const componentType = typeof type; - - if (componentType === 'function') { - if (isClassComponent(type)) { - vNodeTag = ClassComponent; - } - } else if (componentType === 'string') { - vNodeTag = DomComponent; - } else if (type === TYPE_SUSPENSE) { - vNodeTag = SuspenseComponent; - } else if (componentType === 'object' && type !== null && typeMap[type.vtype]) { - vNodeTag = typeMap[type.vtype]; - isLazy = type.vtype === TYPE_LAZY; - } else { - throw Error(`Component type is invalid, got: ${type == null ? type : componentType}`); - } - return { vNodeTag, isLazy }; -} - export function createFragmentVNode(fragmentKey, fragmentProps) { const vNode = newVirtualNode(Fragment, fragmentKey, fragmentProps); vNode.shouldUpdate = true; @@ -127,7 +105,24 @@ export function createPortalVNode(portal) { } export function createUndeterminedVNode(type, key, props) { - const { vNodeTag, isLazy } = getVNodeTag(type); + let vNodeTag = ClsOrFunComponent; + let isLazy = false; + const componentType = typeof type; + + if (componentType === 'function') { + if (isClassComponent(type)) { + vNodeTag = ClassComponent; + } + } else if (componentType === 'string') { + vNodeTag = DomComponent; + } else if (type === TYPE_SUSPENSE) { + vNodeTag = SuspenseComponent; + } else if (componentType === 'object' && type !== null && typeMap[type.vtype]) { + vNodeTag = typeMap[type.vtype]; + isLazy = type.vtype === TYPE_LAZY; + } else { + throw Error(`Component type is invalid, got: ${type == null ? type : componentType}`); + } const vNode = newVirtualNode(vNodeTag, key, props); vNode.type = type;