Код выглядит так:
class App extends Component {
state = {
data: [
{disc: 'Получить пенсию', chekedItem: false, id:'435'},
{disc: 'dfdfgf', chekedItem: false, id:'545'},
{disc: 'dfdfgf', chekedItem: false, id:'565'},
{disc: 'dfdfgf', chekedItem: false, id:'111'},
],
}
onCheked = (id, e) => {
if(e.target === e.currentTarget){
this.setState(({data}) => {
const idx = data.findIndex(elem => elem.id === id);
const old = data[idx]
const newItem = {...old, chekedItem: !chekedItem};
const before = data.slice(0 ,idx);
const after = data.slice(idx + 1);
const newArr = [...before, newItem, ...after];
return{
data: newArr
}
})
}
}
render() {
return(
<div className='mainLayer'>
<div className='todoLayer'>
<TodoHeader/>
<TodoForm addItem={this.addItem}/>
<TodoList post={this.state.data} onCheked={this.onCheked} deleteItem={this.deleteItem}/>
</div>
</div>
)
}
}
export default App;
Ошибка: chekedItem' is not defined no-undef