1π
β
I tested your code and all props are updating normally, however, the reason that isWorking
is updating while selectedTaskIdProp
does not, seem to be from the id
attribute of res[0].task
which does not have this attribute. Therefore, you should check if it has this attribute before passing it to the child, through something like:
:selectedTaskIdProp="(isWorking && selectedTask && selectedTask.id) ? selectedTask.id : undefined"
However, the main problem is in the response, so make sure to add the id to it in order to be passed to the child.
EDIT AFTER DEBUGGING THE SANDBOX:
You are setting selectedTaskID
in the data
of the child directly to the value of the passed prop
, which wonβt work. The right way is to pass the value in created()
of the child component as follows:
data() {
return {
selectedTaskIndex: undefined,
selectedTaskID:null, //update this
tasks: []
};
},
created: function() {
this.tasks = api.getTasks();
console.log('set this.tasks in TasksLists.vue to')
console.log(this.tasks);
this.selectedTaskID = this.selectedTaskIDProp; //update this
}
π€Majed Badawi
Source:stackexchange.com