-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Closed
Description
Vue version
3.5.13
Link to minimal reproduction
Steps to reproduce
- Fill the child component's input form with any sentences, it will edit the parent as well
What is expected?
The parent component value should not be edited because there is no emit or anything else that can update parent object value. This violence One Way Dataflow
- child able to edit parent only from a Props
What is actually happening?
When the parent pass object to props then the child component receive and connect it to a variable using onMounted
method, this make the parent also edited when child did.
const props = defineProps(
{
parentMsg: Object
}
)
const childObj = ref({
msg: ""
})
onMounted(() => {
// parent will be editted as well even there is no emit
childObj.value = props.parentMsg
})
System Info
Any additional comments?
for now, to avoid this issue. I connect the variable with object spread operator
onMounted(() => {
childObj.value = {...props.parentObj};
});
No response
Metadata
Metadata
Assignees
Labels
No labels