How would I pass an array into a setState? As you can see there is a checkbox that renders and once onchange is called the id is put into the state but if there are multiple checkboxes it overwrites each time onchange is called.
getInitialState() {
return {
listid: []
}
},
handleChange() {
this.setState({
listid: e.target.name,
});
},
renderCheckbox() {
const data = this.state.data || [];
return data.map((list, i) => {
return (
<Checkbox
key={i}
onChange={this.handleChange}
name={list.id}
value="Yes"
label={description}
/>
);
});
},
listidindicating if the checkbox is checked or not?