toRefs(proxyRefs(...)) works, but warns that toRefs() expects a reactive object but received a plain one

This issue has been tracked since 2022-08-15.

Version

2.7.8

Steps to reproduce

The following code

toRefs(proxyRefs({ foo: computed(() => 1) }))

prints a warning

vue.runtime.esm.js:4560 [Vue warn]: toRefs() expects a reactive object but received a plain one.

What is expected?

No warning

What is actually happening?

Warning in console

sodatea wrote this answer on 2022-08-15

I think it's expected behavior.

proxyRefs() does not return a reactive object.
Its type signature is ShallowUnwrapRef<T>, while reactive() returns an UnwrapNestedRefs<T>

It only happens to be the case that the toRefs()'s internal implementation can handle ShallowUnwrapRef<T>'s structure. But toRefs()'s documented usage is only to handle reactive objects.
So I think it's better to create a custom utility function to handle it than to reuse toRefs() for this purpose.

More Details About Repo
Owner Name vuejs
Repo Name vue
Full Name vuejs/vue
Language TypeScript
Created Date 2013-07-29
Updated Date 2022-10-03
Star Count 199758
Watcher Count 6095
Fork Count 32874
Issue Count 590

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date