Reputation: 29
I'm trying to figure out how to pass updated props to child component. For example,
// parent component
// temp is an reactive object
<Child :temp="temp">
and in Child component,when temp gets modified, the temp props isn't changed.
I'm using script-setup in vue3.
Can you please help me with this issue?
Upvotes: 0
Views: 73
Reputation: 13
To see the change, set up a watcher in the child component like this.
watch(() => props.temp, (newValue, oldValue) => {
console.log(props.temp);
});
If the variable "temp" changes in the parent component, this watcher should trigger.
Upvotes: 0
Reputation: 401
Are you modifying temp in child component? You should avoid manipulation of props.
Otherwise: Are you assigning temp to another variable? It's easy to lose reactivity when doing so, I have learned.
If you provide a little more context your question might get more helpful answers.
Upvotes: 0