I have module where I need to uncheck or check the data using checkbox. Now the problem is I need to slice the push value if the user uncheck it based on the target value. Currently when i try to console log the index it result -1 meaning: "it is not present" I will show you guys my sample code and sample attached image for the reference to make more detailed..
Code:
var array = [...this.state.checkboxVal];
console.log(e.target.value,"my index")
var index = array.indexOf(parseInt(e.target.value));
console.log(index);
if (index > -1) {
array.splice(index, 1);
await this.setState({ checkboxVal: array });
}
console.log(this.state.checkboxVal);
The Expected Output: The Index 1 should be remove

this.setStateisn't anasyncfunction, it can't be awaited.