fix(reactivity): avoid cross-component dependency leaks in setup()

This commit is contained in:
Evan You
2020-02-17 23:14:07 -05:00
parent 202532c301
commit d9d63f21b1
5 changed files with 27 additions and 7 deletions

View File

@@ -1,5 +1,10 @@
import { VNode, VNodeChild, isVNode } from './vnode'
import { ReactiveEffect, shallowReadonly } from '@vue/reactivity'
import {
ReactiveEffect,
shallowReadonly,
pauseTracking,
resetTracking
} from '@vue/reactivity'
import {
PublicInstanceProxyHandlers,
ComponentPublicInstance,
@@ -341,12 +346,14 @@ function setupStatefulComponent(
currentInstance = instance
currentSuspense = parentSuspense
pauseTracking()
const setupResult = callWithErrorHandling(
setup,
instance,
ErrorCodes.SETUP_FUNCTION,
[propsProxy, setupContext]
)
resetTracking()
currentInstance = null
currentSuspense = null