fix(script-setup): ensure useContext() return valid context

This commit is contained in:
Evan You
2020-11-26 09:25:35 -05:00
parent a764814b8e
commit 73cdb9d420
2 changed files with 13 additions and 3 deletions

View File

@@ -746,7 +746,9 @@ const attrHandlers: ProxyHandler<Data> = {
}
}
function createSetupContext(instance: ComponentInternalInstance): SetupContext {
export function createSetupContext(
instance: ComponentInternalInstance
): SetupContext {
const expose: SetupContext['expose'] = exposed => {
if (__DEV__ && instance.exposed) {
warn(`expose() should be called only once per setup().`)