wip: disable tracking in all hooks
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
import { callWithAsyncErrorHandling, ErrorTypeStrings } from './errorHandling'
|
||||
import { warn } from './warning'
|
||||
import { capitalize } from '@vue/shared'
|
||||
import { pauseTracking, resumeTracking } from '@vue/reactivity'
|
||||
|
||||
function injectHook(
|
||||
type: LifecycleHooks,
|
||||
@@ -16,12 +17,16 @@ function injectHook(
|
||||
) {
|
||||
if (target) {
|
||||
;(target[type] || (target[type] = [])).push((...args: any[]) => {
|
||||
// disable tracking inside all lifecycle hooks
|
||||
// since they can potentially be called inside effects.
|
||||
pauseTracking()
|
||||
// Set currentInstance during hook invocation.
|
||||
// This assumes the hook does not synchronously trigger other hooks, which
|
||||
// can only be false when the user does something really funky.
|
||||
setCurrentInstance(target)
|
||||
const res = callWithAsyncErrorHandling(hook, target, type, args)
|
||||
setCurrentInstance(null)
|
||||
resumeTracking()
|
||||
return res
|
||||
})
|
||||
} else if (__DEV__) {
|
||||
|
||||
Reference in New Issue
Block a user