}
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))
}