Trying to get e.target.data
from the objects generated. console.log
displays they have props
with the data
value I assigned them with. How are event specific objects called? I need to access the original value and also want to onClick
delete them. But so far everything i tried, only returns _this2 TypeError (is not a function), or data i tried to pass with the onClick
handler wasn't passed. this.props.plz_zwischen
is a simple array of strings and passed from parent Component.
import React, { Component } from 'react';
export default class checkBox extends Component {
constructor(){
super();
this.state = {
checkboxState: false
};
this.toggle = this.toggle.bind(this);
}
toggle(e){
console.log('toggle was triggered');
}
render(){
let miniBox = this.props.plz_zwischen.map(function(a, index){
return <li key={index} data={a}> <label> {a} </label> <input type="checkbox" onClick={(e) => this.toggle()} /></li>;
});
return(
<div>
<ul id="rowlist">
{miniBox}
</ul>
</div>
);
}
}
Aucun commentaire:
Enregistrer un commentaire