Match-id-1e7778df481951bd1082406e28f7713d3ca5e6b6
This commit is contained in:
parent
a332ba1290
commit
da66b70642
|
@ -106,6 +106,13 @@ export function captureRender(processing: VNode): VNode | null {
|
||||||
|
|
||||||
resetDepContexts(processing);
|
resetDepContexts(processing);
|
||||||
|
|
||||||
|
// suspense打断后,再次render只需初次渲染
|
||||||
|
if (processing.isSuspended) {
|
||||||
|
mountInstance(ctor, processing, nextProps);
|
||||||
|
processing.isSuspended = false;
|
||||||
|
return createChildren(ctor, processing);
|
||||||
|
}
|
||||||
|
|
||||||
// 通过 shouldUpdate 判断是否要复用 children,该值和props,state,context的变化,shouldComponentUpdate,forceUpdate api的调用结果有关
|
// 通过 shouldUpdate 判断是否要复用 children,该值和props,state,context的变化,shouldComponentUpdate,forceUpdate api的调用结果有关
|
||||||
let shouldUpdate;
|
let shouldUpdate;
|
||||||
const inst = processing.realNode;
|
const inst = processing.realNode;
|
||||||
|
@ -166,9 +173,3 @@ export function captureRender(processing: VNode): VNode | null {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function bubbleRender(processing: VNode) {}
|
export function bubbleRender(processing: VNode) {}
|
||||||
|
|
||||||
// 用于未完成的类组件
|
|
||||||
export function getIncompleteClassComponent(clazz, processing: VNode, nextProps: object): VNode | null {
|
|
||||||
mountInstance(clazz, processing, nextProps);
|
|
||||||
return createChildren(clazz, processing);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
import type {VNode} from '../Types';
|
|
||||||
|
|
||||||
import {mergeDefaultProps} from './LazyComponent';
|
|
||||||
import {ClassComponent} from '../vnode/VNodeTags';
|
|
||||||
import {resetDepContexts} from '../components/context/Context';
|
|
||||||
import {getIncompleteClassComponent} from './ClassComponent';
|
|
||||||
|
|
||||||
function captureIncompleteClassComponent(processing, Component, nextProps) {
|
|
||||||
processing.tag = ClassComponent;
|
|
||||||
|
|
||||||
resetDepContexts(processing);
|
|
||||||
|
|
||||||
return getIncompleteClassComponent(Component, processing, nextProps);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function captureRender(processing: VNode): VNode | null {
|
|
||||||
const Component = processing.type;
|
|
||||||
const unresolvedProps = processing.props;
|
|
||||||
const resolvedProps =
|
|
||||||
processing.isLazyComponent
|
|
||||||
? mergeDefaultProps(Component, unresolvedProps)
|
|
||||||
: unresolvedProps;
|
|
||||||
|
|
||||||
return captureIncompleteClassComponent(processing, Component, resolvedProps);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function bubbleRender(processing: VNode) {}
|
|
|
@ -6,7 +6,6 @@ import {
|
||||||
ClassComponent,
|
ClassComponent,
|
||||||
ForwardRef,
|
ForwardRef,
|
||||||
FunctionComponent,
|
FunctionComponent,
|
||||||
IncompleteClassComponent,
|
|
||||||
SuspenseComponent,
|
SuspenseComponent,
|
||||||
} from '../vnode/VNodeTags';
|
} from '../vnode/VNodeTags';
|
||||||
import {pushForceUpdate} from '../UpdateHandler';
|
import {pushForceUpdate} from '../UpdateHandler';
|
||||||
|
@ -179,7 +178,7 @@ export function handleSuspenseChildThrowError(parent: VNode, processing: VNode,
|
||||||
if (processing.tag === ClassComponent) {
|
if (processing.tag === ClassComponent) {
|
||||||
if (processing.isCreated) {
|
if (processing.isCreated) {
|
||||||
// 渲染类组件场景,要标志未完成(否则会触发componentWillUnmount)
|
// 渲染类组件场景,要标志未完成(否则会触发componentWillUnmount)
|
||||||
processing.tag = IncompleteClassComponent;
|
processing.isSuspended = true ;
|
||||||
} else {
|
} else {
|
||||||
// 类组件更新,标记强制更新,否则被memo等优化跳过
|
// 类组件更新,标记强制更新,否则被memo等优化跳过
|
||||||
pushForceUpdate(processing);
|
pushForceUpdate(processing);
|
||||||
|
|
|
@ -9,7 +9,6 @@ import * as DomComponentRender from './DomComponent';
|
||||||
import * as DomPortalRender from './DomPortal';
|
import * as DomPortalRender from './DomPortal';
|
||||||
import * as TreeRootRender from './TreeRoot';
|
import * as TreeRootRender from './TreeRoot';
|
||||||
import * as DomTextRender from './DomText';
|
import * as DomTextRender from './DomText';
|
||||||
import * as IncompleteClassComponentRender from './IncompleteClassComponent';
|
|
||||||
import * as LazyComponentRender from './LazyComponent';
|
import * as LazyComponentRender from './LazyComponent';
|
||||||
import * as MemoComponentRender from './MemoComponent';
|
import * as MemoComponentRender from './MemoComponent';
|
||||||
import * as SuspenseComponentRender from './SuspenseComponent';
|
import * as SuspenseComponentRender from './SuspenseComponent';
|
||||||
|
@ -25,7 +24,6 @@ import {
|
||||||
DomPortal,
|
DomPortal,
|
||||||
TreeRoot,
|
TreeRoot,
|
||||||
DomText,
|
DomText,
|
||||||
IncompleteClassComponent,
|
|
||||||
LazyComponent,
|
LazyComponent,
|
||||||
MemoComponent,
|
MemoComponent,
|
||||||
SuspenseComponent,
|
SuspenseComponent,
|
||||||
|
@ -46,7 +44,6 @@ export default {
|
||||||
[DomPortal]: DomPortalRender,
|
[DomPortal]: DomPortalRender,
|
||||||
[TreeRoot]: TreeRootRender,
|
[TreeRoot]: TreeRootRender,
|
||||||
[DomText]: DomTextRender,
|
[DomText]: DomTextRender,
|
||||||
[IncompleteClassComponent]: IncompleteClassComponentRender,
|
|
||||||
[LazyComponent]: LazyComponentRender,
|
[LazyComponent]: LazyComponentRender,
|
||||||
[MemoComponent]: MemoComponentRender,
|
[MemoComponent]: MemoComponentRender,
|
||||||
[SuspenseComponent]: SuspenseComponentRender,
|
[SuspenseComponent]: SuspenseComponentRender,
|
||||||
|
|
|
@ -32,7 +32,7 @@ import {
|
||||||
callEffectRemove,
|
callEffectRemove,
|
||||||
callUseEffects,
|
callUseEffects,
|
||||||
callUseLayoutEffectCreate,
|
callUseLayoutEffectCreate,
|
||||||
callUseLayoutEffectRemove
|
callUseLayoutEffectRemove,
|
||||||
} from './HookEffectHandler';
|
} from './HookEffectHandler';
|
||||||
import { handleSubmitError } from '../ErrorHandler';
|
import { handleSubmitError } from '../ErrorHandler';
|
||||||
import {
|
import {
|
||||||
|
@ -192,7 +192,8 @@ function unmountVNode(vNode: VNode): void {
|
||||||
|
|
||||||
const instance = vNode.realNode;
|
const instance = vNode.realNode;
|
||||||
// 当constructor中抛出异常时,instance会是null,这里判断一下instance是否为空
|
// 当constructor中抛出异常时,instance会是null,这里判断一下instance是否为空
|
||||||
if (instance && typeof instance.componentWillUnmount === 'function') {
|
// suspense打断时不需要触发WillUnmount
|
||||||
|
if (instance && typeof instance.componentWillUnmount === 'function' && !vNode.isSuspended) {
|
||||||
callComponentWillUnmount(vNode, instance);
|
callComponentWillUnmount(vNode, instance);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -16,7 +16,6 @@ import {
|
||||||
ContextProvider,
|
ContextProvider,
|
||||||
Profiler,
|
Profiler,
|
||||||
MemoComponent,
|
MemoComponent,
|
||||||
IncompleteClassComponent,
|
|
||||||
} from './VNodeTags';
|
} from './VNodeTags';
|
||||||
import type { VNodeTag } from './VNodeTags';
|
import type { VNodeTag } from './VNodeTags';
|
||||||
import type { RefType, ContextType, SuspenseState } from '../Types';
|
import type { RefType, ContextType, SuspenseState } from '../Types';
|
||||||
|
@ -158,8 +157,6 @@ export class VNode {
|
||||||
break;
|
break;
|
||||||
case Profiler:
|
case Profiler:
|
||||||
break;
|
break;
|
||||||
case IncompleteClassComponent:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,6 @@ export function clearVNode(vNode: VNode) {
|
||||||
vNode.hooks = null;
|
vNode.hooks = null;
|
||||||
vNode.props = null;
|
vNode.props = null;
|
||||||
vNode.parent = null;
|
vNode.parent = null;
|
||||||
// mark
|
|
||||||
vNode.suspenseState = null;
|
vNode.suspenseState = null;
|
||||||
vNode.changeList = null;
|
vNode.changeList = null;
|
||||||
vNode.effectList = null;
|
vNode.effectList = null;
|
||||||
|
|
Loading…
Reference in New Issue