Given the following piece of code, I am trying to get (console log) the text values in the <li>
but I keep getting undefined
. I have tried various solutions on SO but to no resolve.
export class List extends React.Component<{}, IState> {
constructor(props) {
super(props);
this.state = {
list: ['top', 'middle', 'bottom']
}
this.updateReview = this.updateReview.bind(this);
}
updateReview = (e) => {
// e.preventDefault()
console.log(e.target.value);
// console.log(e.currentTarget.id);
}
render() {
let { list } = this.state;
return (
<div>
{list.map((value, key) => {
return (
<li onClick={(x)=>this.updateReview(x)} key={key}>
{value}
</li>
);
})
}
</div>
);
}
}