diff --git a/libs/horizon/src/renderer/render/ClassComponent.ts b/libs/horizon/src/renderer/render/ClassComponent.ts index 83cccb11..6db4dcf2 100644 --- a/libs/horizon/src/renderer/render/ClassComponent.ts +++ b/libs/horizon/src/renderer/render/ClassComponent.ts @@ -103,7 +103,15 @@ function markLifeCycle(processing: VNode, nextProps: object, shouldUpdate: Boole } // 用于类组件 -export function captureClassComponent(processing: VNode, clazz: any, nextProps: object): VNode | null { +export function captureRender(processing: VNode): VNode | null { + let clazz = processing.type; + let nextProps = processing.props; + if (processing.isLazyComponent) { + nextProps = mergeDefaultProps(clazz, nextProps); + if (processing.promiseResolve) { // 该函数被 lazy 组件使用,未加载的组件需要加载组件的真实内容 + clazz = clazz._load(clazz._content); + } + } const isOldCxtExist = isOldProvider(clazz); cacheOldCtx(processing, isOldCxtExist); @@ -175,13 +183,6 @@ export function captureClassComponent(processing: VNode, clazz: any, nextProps: } } -export function captureRender(processing: VNode): VNode | null { - const clazz = processing.type; - const props = processing.props; - const nextProps = processing.isLazyComponent ? mergeDefaultProps(clazz, props) : props; - return captureClassComponent(processing, clazz, nextProps); -} - export function bubbleRender(processing: VNode) { if (isOldProvider(processing.type)) { resetOldCtx(processing); diff --git a/libs/horizon/src/renderer/render/LazyComponent.ts b/libs/horizon/src/renderer/render/LazyComponent.ts index a1f911ad..7f81ab2a 100644 --- a/libs/horizon/src/renderer/render/LazyComponent.ts +++ b/libs/horizon/src/renderer/render/LazyComponent.ts @@ -10,7 +10,7 @@ import { } from '../vnode/VNodeTags'; import { throwIfTrue } from '../utils/throwIfTrue'; import { captureFunctionComponent } from './FunctionComponent'; -import { captureClassComponent } from './ClassComponent'; +import { captureRender as captureClassComponent } from './ClassComponent'; import { captureMemoComponent } from './MemoComponent'; export function bubbleRender() { }