-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
watch
a ref props object not take effect
#10970
Comments
watch( () => props.propData, () => {})
|
https://github.com/vuejs/core/blob/main/packages/runtime-core/src/apiWatch.ts#L241-L281 if (isRef(source)) {
getter = () => source.value
forceTrigger = isShallow(source)
} else if (isReactive(source)) {
getter = () => reactiveGetter(source)
forceTrigger = true
} else if (isArray(source)) {
isMultiSource = true
forceTrigger = source.some(s => isReactive(s) || isShallow(s))
getter = () =>
source.map(s => {
if (isRef(s)) {
return s.value
} else if (isReactive(s)) {
return reactiveGetter(s)
} else if (isFunction(s)) {
return callWithErrorHandling(s, instance, ErrorCodes.WATCH_GETTER)
} else {
__DEV__ && warnInvalidSource(s)
}
})
} else if (isFunction(source)) {
if (cb) {
// getter with cb
getter = () =>
callWithErrorHandling(source, instance, ErrorCodes.WATCH_GETTER) But I saw it will all convert to getter anyway, is there anything I missed? |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Vue version
3.4.21
Link to minimal reproduction
Playground reproduction
Steps to reproduce
Child.vue
, define a props meanspropData
, type isPropData
propData.value
, child componentwatch(props.propData)
will not watch it change.But template rerender correctly. and watch a getter
watch(()=>props.propData)
will take effect.What is expected?
When propData changed,
watch(props.propData)
will watched this change, same as tamplate rerender andwatch(()=>props.propData)
What is actually happening?
When propData changed,
watch(props.propData)
not take effect.When clicked the
changeProps1
button,then clickchangeProps2
will also invalidSystem Info
No response
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: