Home / Function/ callHook() — vue Function Reference

callHook() — vue Function Reference

Architecture documentation for the callHook() function in lifecycle.ts from the vue codebase.

Function typescript CoreRuntime Instance calls 2 called by 7

Entity Profile

Dependency Diagram

graph TD
  f8064a1e_1b6a_274a_f334_111faf594604["callHook()"]
  f3560440_54c1_5663_36f8_c7de54d7310b["lifecycle.ts"]
  f8064a1e_1b6a_274a_f334_111faf594604 -->|defined in| f3560440_54c1_5663_36f8_c7de54d7310b
  7cb38e61_0473_03dc_2a46_4308c941e8cf["initMixin()"]
  7cb38e61_0473_03dc_2a46_4308c941e8cf -->|calls| f8064a1e_1b6a_274a_f334_111faf594604
  8c103bae_ceb4_9609_cad2_36c8a086376e["lifecycleMixin()"]
  8c103bae_ceb4_9609_cad2_36c8a086376e -->|calls| f8064a1e_1b6a_274a_f334_111faf594604
  635aa950_844d_5a47_5cc5_4e33768708f9["mountComponent()"]
  635aa950_844d_5a47_5cc5_4e33768708f9 -->|calls| f8064a1e_1b6a_274a_f334_111faf594604
  c839785a_cc49_21a8_563d_d8789c68747b["activateChildComponent()"]
  c839785a_cc49_21a8_563d_d8789c68747b -->|calls| f8064a1e_1b6a_274a_f334_111faf594604
  043a558f_df1f_5f57_8b30_ee24fc5b407f["deactivateChildComponent()"]
  043a558f_df1f_5f57_8b30_ee24fc5b407f -->|calls| f8064a1e_1b6a_274a_f334_111faf594604
  d58310dd_8787_86b4_93c2_433f1f914fad["callUpdatedHooks()"]
  d58310dd_8787_86b4_93c2_433f1f914fad -->|calls| f8064a1e_1b6a_274a_f334_111faf594604
  4accbb05_fb35_7066_14cf_218d3f576a8a["componentVNodeHooks.insert()"]
  4accbb05_fb35_7066_14cf_218d3f576a8a -->|calls| f8064a1e_1b6a_274a_f334_111faf594604
  46145e02_0be2_a179_3c66_d786e8df82f3["pushTarget()"]
  f8064a1e_1b6a_274a_f334_111faf594604 -->|calls| 46145e02_0be2_a179_3c66_d786e8df82f3
  f641f94c_5096_9084_3285_10f3d148c139["popTarget()"]
  f8064a1e_1b6a_274a_f334_111faf594604 -->|calls| f641f94c_5096_9084_3285_10f3d148c139
  style f8064a1e_1b6a_274a_f334_111faf594604 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/core/instance/lifecycle.ts lines 394–421

export function callHook(
  vm: Component,
  hook: string,
  args?: any[],
  setContext = true
) {
  // #7573 disable dep collection when invoking lifecycle hooks
  pushTarget()
  const prevInst = currentInstance
  const prevScope = getCurrentScope()
  setContext && setCurrentInstance(vm)
  const handlers = vm.$options[hook]
  const info = `${hook} hook`
  if (handlers) {
    for (let i = 0, j = handlers.length; i < j; i++) {
      invokeWithErrorHandling(handlers[i], vm, args || null, vm, info)
    }
  }
  if (vm._hasHookEvent) {
    vm.$emit('hook:' + hook)
  }
  if (setContext) {
    setCurrentInstance(prevInst)
    prevScope && prevScope.on()
  }

  popTarget()
}

Domain

Subdomains

Frequently Asked Questions

What does callHook() do?
callHook() is a function in the vue codebase, defined in src/core/instance/lifecycle.ts.
Where is callHook() defined?
callHook() is defined in src/core/instance/lifecycle.ts at line 394.
What does callHook() call?
callHook() calls 2 function(s): popTarget, pushTarget.
What calls callHook()?
callHook() is called by 7 function(s): activateChildComponent, callUpdatedHooks, componentVNodeHooks.insert, deactivateChildComponent, initMixin, lifecycleMixin, mountComponent.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free