Skip to content

Commit 7343f7c

Browse files
authored
dx(runtime-core): fix warning message for useSlots, useAttrs invocation with missing instance (#13647)
1 parent 8cfc10a commit 7343f7c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/runtime-core/src/apiSetupHelpers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,17 +382,17 @@ export function withDefaults<
382382
}
383383

384384
export function useSlots(): SetupContext['slots'] {
385-
return getContext().slots
385+
return getContext('useSlots').slots
386386
}
387387

388388
export function useAttrs(): SetupContext['attrs'] {
389-
return getContext().attrs
389+
return getContext('useAttrs').attrs
390390
}
391391

392-
function getContext(): SetupContext {
392+
function getContext(calledFunctionName: string): SetupContext {
393393
const i = getCurrentInstance()!
394394
if (__DEV__ && !i) {
395-
warn(`useContext() called without active instance.`)
395+
warn(`${calledFunctionName}() called without active instance.`)
396396
}
397397
return i.setupContext || (i.setupContext = createSetupContext(i))
398398
}

0 commit comments

Comments
 (0)