From b7183f10827eb2a5f6222dcd14922e1e10927009 Mon Sep 17 00:00:00 2001 From: * <8> Date: Wed, 23 Feb 2022 14:51:46 +0800 Subject: [PATCH] Match-id-97c0af573376bf091e9db7228d7cea81484ba94a --- .../src/renderer/render/ClassComponent.ts | 17 +++++++++-------- .../src/renderer/render/LazyComponent.ts | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) 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() { }