lundi 12 février 2018

React Checkbox onCheck get key value

I am currently working on a website I am building with React, and I am not able to get the Checkbox key value from the onChange event. This is what my code looks like:

handleChange = (e) => {
    console.log('it works');
    console.log(e.target.key);
}

And my Checkbox code:

<Table.Cell><Checkbox key={singleNews.key} name="myCheckBox1" onChange={this.handleChange}/></Table.Cell>

It simply prints out 'it works', and 'undefined'. I have also used 'this.handleChange = this.handleChange.bind(this) in my constructor. Could anyone please help me find out what the error might be? For the record; I am currently using the Semantic UI React framework - could this be the problem?

Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire