fix(runtime-core): fix async component ref handling (#3191)

fix #3188
This commit is contained in:
HcySunYang
2021-03-02 04:00:32 +08:00
committed by GitHub
parent 3f9906a2f8
commit 7562e72c2b
2 changed files with 53 additions and 2 deletions

View File

@@ -313,9 +313,13 @@ export const setRef = (
}
let value: ComponentPublicInstance | RendererNode | Record<string, any> | null
if (!vnode || isAsyncWrapper(vnode)) {
if (!vnode) {
// means unmount
value = null
} else {
// when mounting async components, nothing needs to be done,
// because the template ref is forwarded to inner component
if (isAsyncWrapper(vnode)) return
if (vnode.shapeFlag & ShapeFlags.STATEFUL_COMPONENT) {
value = vnode.component!.exposed || vnode.component!.proxy
} else {