MCPcopy
hub / github.com/vuejs/composition-api / getCurrentInstanceForFn

Function getCurrentInstanceForFn

src/utils/helper.ts:11–24  ·  view source on GitHub ↗
(
  hook: string,
  target?: ComponentInternalInstance | null
)

Source from the content-addressed store, hash-verified

9import { warn } from './utils'
10
11export function getCurrentInstanceForFn(
12 hook: string,
13 target?: ComponentInternalInstance | null
14): ComponentInternalInstance | null {
15 target = target || getCurrentInstance()
16 if (__DEV__ && !target) {
17 warn(
18 `${hook} is called when there is no active component instance to be ` +
19 `associated with. ` +
20 `Lifecycle injection APIs can only be used during execution of setup().`
21 )
22 }
23 return target
24}
25
26export function defineComponentInstance<V extends Vue = Vue>(
27 Ctor: VueConstructor<V>,

Callers 2

createLifeCycleFunction · 0.90
provideFunction · 0.90

Calls 2

getCurrentInstanceFunction · 0.90
warnFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…