my Objective is to remove the list of selected objects, if i checkAll then it should show empty list or if i select one item from the Table then it should remove the selected item from the list. But i couldn't able to get the checked object.
Json look like :
const data =[
{
id: "12shgdfyd78"
name: "ABC"
isSelected: true
phone: "1234569874"
},
{
id: "18htfdwcfe78"
name: "EFG"
isSelected: true
phone: "9587463215"
}
]
if i select the first one then the whole object need to appear, But could not able to get it.
If have tried in this way:
handleCheck = (e) => {
let value = e.target.name //will get the phone number
let checked = e.target.checked;
let checkedList = this.props.data.map((item)=> item.phone == value? Object.assign(item,{isSelected: checked,}): item
this.setState({checkItems: checkedList})
}
handleSubmit = () => {
const data = this.state.checkItems.filter(item=>item.isSelected).map(item=>item.phone)
}
But didn't get the object.
Can anyone please help me in this query?