Below is my partial code but my question is very simple, how can I get says data-id=\"1\" to my function when user clicked on the li?
render(){
You can do this as follows :
class Test extends React.Component {
constructor(props){
super(props);
this.state = {
items: [
{item: "item", id: 1},
{item1: "item1", id: 2}
]
}
}
handleClick(id, e){
alert(id);
}
render(){
return(
{this.state.items.map((item,i) =>
- {item.name}
)}
)
}
}
React.render( , document.getElementById('container'));
Here is jsfiddle.