-
Notifications
You must be signed in to change notification settings - Fork 344
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
feat: proxyRefs
method and ShallowUnwrapRefs
type
#456
Conversation
BREAKING CHANGE: template auto ref unwrapping are now applied shallowly, i.e. only at the root level. See vuejs/core#1682 for more details.
expect(warn).not.toHaveBeenCalled() | ||
expect(vm.$el.textContent).toBe('42') | ||
}) | ||
// it('not warn doing toRef on props', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is caused because the props are marked as raw
Open for suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess we can mark the props to shallow reactive and change the test to only tests the top-level toRefs
, just like you mentioned in the limitation part?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Props are already reactive, only the nested ref are not
composition-api/test/setup.spec.js
Lines 336 to 371 in 030d02c
it('toRefs(props) should not warn', async () => { | |
let a | |
const child = { | |
template: `<div/>`, | |
props: { | |
r: Number, | |
}, | |
setup(props) { | |
a = toRefs(props).r | |
}, | |
} | |
const vm = new Vue({ | |
template: `<child :r="r"/>`, | |
components: { | |
child, | |
}, | |
data() { | |
return { | |
r: 1, | |
} | |
}, | |
}).$mount() | |
expect(a.value).toBe(1) | |
vm.r = 3 | |
await Vue.nextTick() | |
expect(a.value).toBe(3) | |
expect(warn).not.toHaveBeenCalled() | |
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine by leaving a note in the limitation for this.
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
vuejs/core#1682