refactor(reactivity): reduce variable access (#4366)

This commit is contained in:
zhangenming 2021-08-18 00:11:52 +08:00 committed by GitHub
parent c68cba82ea
commit d8da4214fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -221,9 +221,8 @@ export function toRef<T extends object, K extends keyof T>(
object: T,
key: K
): ToRef<T[K]> {
return isRef(object[key])
? object[key]
: (new ObjectRefImpl(object, key) as any)
const val = object[key]
return isRef(val) ? val : (new ObjectRefImpl(object, key) as any)
}
// corner case when use narrows type