Skip to content

Commit a0bd1f5

Browse files
authored
refactor: migrate to getCurrentInstance API (#12958)
1 parent 01a1222 commit a0bd1f5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

packages/runtime-core/src/apiInject.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { isFunction } from '@vue/shared'
2-
import { currentInstance } from './component'
3-
import { currentRenderingInstance } from './componentRenderContext'
2+
import { currentInstance, getCurrentInstance } from './component'
43
import { currentApp } from './apiCreateApp'
54
import { warn } from './warning'
65

@@ -51,7 +50,7 @@ export function inject(
5150
) {
5251
// fallback to `currentRenderingInstance` so that this can be called in
5352
// a functional component
54-
const instance = currentInstance || currentRenderingInstance
53+
const instance = getCurrentInstance()
5554

5655
// also support looking up from app-level provides w/ `app.runWithContext()`
5756
if (instance || currentApp) {
@@ -90,5 +89,5 @@ export function inject(
9089
* user. One example is `useRoute()` in `vue-router`.
9190
*/
9291
export function hasInjectionContext(): boolean {
93-
return !!(currentInstance || currentRenderingInstance || currentApp)
92+
return !!(getCurrentInstance() || currentApp)
9493
}

0 commit comments

Comments
 (0)