Skip to content

Commit bd19967

Browse files
author
tony
committed
code style update
1 parent 5898629 commit bd19967

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 { warn } from './warning'
54

65
export interface InjectionKey<T> extends Symbol {}
@@ -45,14 +44,14 @@ export function inject(
4544
) {
4645
// fallback to `currentRenderingInstance` so that this can be called in
4746
// a functional component
48-
const instance = currentInstance || currentRenderingInstance
47+
const instance = getCurrentInstance()
4948
if (instance) {
5049
// #2400
5150
// to support `app.use` plugins,
5251
// fallback to appContext's `provides` if the instance is at root
5352
const provides =
5453
instance.parent == null
55-
? instance.vnode.appContext && instance.vnode.appContext.provides
54+
? instance.vnode.appContext?.provides
5655
: instance.parent.provides
5756

5857
if (provides && (key as string | symbol) in provides) {

0 commit comments

Comments
 (0)