feat: warn when toRefs() receives non-reactive object (#430)
This commit is contained in:
parent
98e9b769e6
commit
a02820d7e0
@ -1,7 +1,7 @@
|
||||
import { track, trigger } from './effect'
|
||||
import { OperationTypes } from './operations'
|
||||
import { isObject } from '@vue/shared'
|
||||
import { reactive } from './reactive'
|
||||
import { reactive, isReactive } from './reactive'
|
||||
import { ComputedRef } from './computed'
|
||||
import { CollectionTypes } from './collectionHandlers'
|
||||
|
||||
@ -47,6 +47,9 @@ export function isRef(r: any): r is Ref {
|
||||
export function toRefs<T extends object>(
|
||||
object: T
|
||||
): { [K in keyof T]: Ref<T[K]> } {
|
||||
if (__DEV__ && !isReactive(object)) {
|
||||
console.warn(`toRefs() expects a reactive object but received a plain one.`)
|
||||
}
|
||||
const ret: any = {}
|
||||
for (const key in object) {
|
||||
ret[key] = toProxyRef(object, key)
|
||||
|
Loading…
x
Reference in New Issue
Block a user