I have written his react component
class RegistrationSpecialNeeds extends React.Component {
constructor(props) {
super(props);
this.state = {"specialneeds": []}
this.isChecked.bind(this)
}
handleChange(event, key) {
console.log('came inside handle checkbox event')
console.log('what is event ' + event.target.checked)
console.log('what is key' + key)
}
isChecked(key) {
if (this.state.specialneeds.indexOf(key) > -1) {true} else {false}
}
render() {
return (
<div>
<label> check all that apply
{
this.props.restrictions.map((restriction, index) =>
<div>
<label>
<input type='checkbox' name='restriction' checked={this.isChecked(restriction.key)} onChange={(e) => this.handleChange(e, restriction.key)}/>{restriction.key}) {restriction.name}
</label>
</div>
)
}
</label>
</div>
)
}
}
<RegistrationSpecialNeeds restrictions={[{key: "a", name: "Dietary Restrictions"}, {key: 'b', name: 'Physical Disabilities'}, {key: 'c', name: 'Medical Needs'}]} />
When I select something in the checkbox I get output
[Log] came inside handle checkbox event (Registration.html, line 29) [Log] what is event undefined (Registration.html, line 30) [Log] what is keya (Registration.html, line 31)
how can I get the event object?