-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
While putting destructured props into toRefs the warning appears [Vue warn] toRefs() expects a reactive object but received a plain one. #13171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
const {...props} = defineProps() // compiled to const props = _createPropsRestProxy(__props, [])
console.log(props) // props is a plain object
const props = defineProps()
console.log(props) // props is a Proxy They are different, see https://vuejs.org/api/sfc-script-setup.html#reactive-props-destructure |
@edison1105 Thanks for the response. But it doesn't solve the problem. This works fine (no toRefs is needed obviously) const props = defineProps<{ myProp: string }>()
provide('context', props) But this emits a warning const { someProp1, someProp2, ...props } = defineProps<{ myProp: string }>()
provide('context', {
extraValue1: 1,
extraValue2: 2,
// ...props this won't work so I need toRefs
...toRefs(props) // this works fine, but warning appears
}) |
@edison1105 don't you think |
@edison1105 can this issue be reopened? |
There is a fix ac43b11 in vapor branch, so it will be fixed when v3.6 is released. |
Uh oh!
There was an error while loading. Please reload this page.
Vue version
3.5.13
Link to minimal reproduction
https://play.vuejs.org/#eNqFkj1PwzAQhv+K5SWtFDlChaUKSIA6wABVYbSEquRSXBLbsp1Qqep/585JSocWtvt4znrvPe/5vbWia4HPee4Lp2xgHkJr76RWjTUusEfTWFY507BEZJQQnkidZz2PJCYBGluvA2DGWF6qLgYYxvGsL2d9Pc9OaJ7y4AujK7URW280CtkTLHmBk6oG92qDMtpLPmexQ711XZvv51gLroV0rBefUHydqW/9jmqSLx14cB1IfuyFtdtA6NuLtxfYYXxsNqZsa6T/aK7Am7oljT320OoSZZ9wUe1TtFPpzbtf7AJoPy5FQok8RF5ytJdMu7T6r9yZuI5zUh/QxfE0ly+5Z8GsoPIps850qgScHS7bn1RqPIQnUAiBjPUI3LISKqVhSflkStQwPkkQD2hJkg4vT+LQFKH/fseZv4A7fHTgyBfcYSZuxNWMH34AEnfgZw==
Steps to reproduce
defineProps
like thisconst { ...props } = defineProps()
props
intotoRefs
toRefs(props))
Note
this works fine
const props = defineProps() toRefs(props))
What is expected?
No warning
What is actually happening?
A warning appears [Vue warn] toRefs() expects a reactive object but received a plain one.
System Info
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: