I'm learning React and am building a simple todo list. I have this object in my initialState
getInitialState:function(){
return {
items: [
{
text:"Buy Fish",
key: "1",
done: 0
}
]
}
},
My TodoList component has this map function
var listItem = this.props.items.map((item, index)=>{
return <li key={item.key}> <input type="checkbox" onChange={(e)=>{this.props.onChange(item.key, e)}} /> <span onClick={()=>{this.props.editItem(item.text)}}>{item.text}</span> <button onClick={()=>this.props.removeItem(item.key)}>x</button> </li>
});
Now I want to click on the checkbox and change the state of the property done to 1.
The onChange prop is leading to a function
itemDone:function(index, e){
var myArray = this.state.items;
var a = e.target.checked;
console.log(index);
},
What is the correct way to change the value from 0 to 1 to that specific item?