Я только начинаю работать с Mobx и пытаюсь добавить действие, которое удаляет элемент из наблюдаемого массива.Что я делаю не так?
Вот магазин:
class ToDoStore {
@observable items = [];
@action addItem = (item) => {
this.items.push(item)
}
@action removeItem = (index) => {
this.items.splice(index, 1)
}
@computed get itemCount(){
return this.items.length;
}
}
Вот App.js:
@inject('ToDoStore')
@observer class App extends Component {
handleRemove = (index) => {
this.props.ToDoStore.removeItem(index);
}
render() {
const {ToDoStore} = this.props;
return (
<div className="App">
{ToDoStore.items.map((item, index )=> <li key={index}>{item}<button onClick={(index) => this.handleRemove(index)}>REMOVE</button></li>)}
</div>
);
}
}
export default App;
Вот ошибка, которую я получаю, когда нажимаюкнопка «удалить»
![enter image description here](https://i.stack.imgur.com/D2eap.png)