I am having multiple locations, on check of the particular location i can able to push those into array on check of checkbox unable to remove from array
handleChange(e){
if(e.target.checked){
let selectedLocations = this.state.selectedLocations;
selectedLocations.push({
name: e.target.name,
isActive: true
});
this.setState({
selectedLocations: selectedLocations
});
}else{
let selectedLocations = this.state.selectedLocations;
}
}
{
locations && locations.map((el, i) => {
return (
<div className="col-md-4">
<div className="form-group">
<input type="checkbox" value="true" name={el.name} onChange={this.handleChange.bind(this)}/><label> {el.name} </label>
</div>
</div>
)
})
}
I want to remove from array after unchecking particular location
Aucun commentaire:
Enregistrer un commentaire