fix(warning): always check for component instance presence when formatting traces

This commit is contained in:
Evan You 2020-04-29 14:41:06 -04:00
parent 5f89674790
commit a0e2c12874

View File

@ -89,8 +89,8 @@ function getComponentTrace(): ComponentTraceStack {
recurseCount: 0 recurseCount: 0
}) })
} }
const parentInstance: ComponentInternalInstance | null = currentVNode.component! const parentInstance: ComponentInternalInstance | null =
.parent currentVNode.component && currentVNode.component.parent
currentVNode = parentInstance && parentInstance.vnode currentVNode = parentInstance && parentInstance.vnode
} }
@ -108,7 +108,7 @@ function formatTrace(trace: ComponentTraceStack): any[] {
function formatTraceEntry({ vnode, recurseCount }: TraceEntry): any[] { function formatTraceEntry({ vnode, recurseCount }: TraceEntry): any[] {
const postfix = const postfix =
recurseCount > 0 ? `... (${recurseCount} recursive calls)` : `` recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``
const isRoot = vnode.component!.parent == null const isRoot = vnode.component ? vnode.component.parent == null : false
const open = ` at <${formatComponentName(vnode.type, isRoot)}` const open = ` at <${formatComponentName(vnode.type, isRoot)}`
const close = `>` + postfix const close = `>` + postfix
return vnode.props return vnode.props