0

Hi i am trying to modify the particular component in the child array but getting the particular error

try is the incoming array from parent.

1 @track sethg;
2 this.sethg = this.try.findIndex(item => item.ter === event.detail.ter);

3 this.try[this.sethg].booleanvariable = false;

on line 3 i am trying to make the incoming value as false , getting below error can anyone find out the possible way to set the value.

['set' on proxy: trap returned falsish for property 'booleanvariable ']
1
0

Data passed from parent component is immutable, i.e. you can not change its value. However, you can deep clone it and make it mutable before changing the value.

this.try = JSON.parse(JSON.stringify(this.try));
0

Since, the data passed from parent component is immutable. I would suggest you not to change the value of it rather create a new variable called tryPrivate and do the following

@api
get try(){
return _try
}

set try(value){
this.tryPrivate = {..value} (if object) or [...value] (if array)
this._try=value;
}

Now, you are free to use the variable tryPrivate in child component and can edit it anytime in js.

Thanks

Not the answer you're looking for? Browse other questions tagged or ask your own question.