From c7a67431fa7e61bcbcc88293fb2e49c787198e2b Mon Sep 17 00:00:00 2001 From: Alex Snezhko Date: Wed, 16 Jul 2025 19:44:46 -0700 Subject: [PATCH] dx(runtime-core): fix warning message for useSlots, useAttrs invocation with missing instance --- packages/runtime-core/src/apiSetupHelpers.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/runtime-core/src/apiSetupHelpers.ts b/packages/runtime-core/src/apiSetupHelpers.ts index 2ddaeb509ad..209b3364cec 100644 --- a/packages/runtime-core/src/apiSetupHelpers.ts +++ b/packages/runtime-core/src/apiSetupHelpers.ts @@ -382,17 +382,17 @@ export function withDefaults< } export function useSlots(): SetupContext['slots'] { - return getContext().slots + return getContext('useSlots').slots } export function useAttrs(): SetupContext['attrs'] { - return getContext().attrs + return getContext('useAttrs').attrs } -function getContext(): SetupContext { +function getContext(calledFunctionName: string): SetupContext { const i = getCurrentInstance()! if (__DEV__ && !i) { - warn(`useContext() called without active instance.`) + warn(`${calledFunctionName}() called without active instance.`) } return i.setupContext || (i.setupContext = createSetupContext(i)) }