fix(keep-alive): fix activated hook invocation on nested components (#1743)

fix #1742
This commit is contained in:
zhangzhonghe
2020-08-06 21:42:52 +08:00
committed by GitHub
parent 00683fce9a
commit 233d191d0d
2 changed files with 34 additions and 1 deletions

View File

@@ -1265,7 +1265,7 @@ function baseCreateRenderer(
if (!instance.isMounted) {
let vnodeHook: VNodeHook | null | undefined
const { el, props } = initialVNode
const { bm, m, a, parent } = instance
const { bm, m, parent } = instance
if (__DEV__) {
startMeasure(instance, `render`)
}
@@ -1324,6 +1324,9 @@ function baseCreateRenderer(
}, parentSuspense)
}
// activated hook for keep-alive roots.
// #1742 activated hook must be accessed after first render
// since the hook may be injected by a child keep-alive
const { a } = instance
if (
a &&
initialVNode.shapeFlag & ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE