At first please see the picture for actually what's going on
The issue is while marked the checkbox then text erasing but I want to update a state field from state array & the functionalities are like below
state = {
items: [
{ id: 1, text: 'Buy milk', done: true },
{ id: 2, text: 'Deed cat', done: false },
{ id: 3, text: 'Wash floor', done: false }
]
};
markItemDone = (i) => {
this.setState(state => {
const items = state.items.map((item) => {
if (item.id === i){
return item.done = true;
} else {
return item;
}
});
return {
items,
};
});
}
JSX:
<input
type="checkbox"
onClick={() => this.markItemDone(item.id)}
defaultChecked={item.done ? true : null}
/>
I'm not finding the actual solution.
Thanks
