Должен ли я использовать нумерацию страниц? Всякий раз, когда я нажимаю эту кнопку <Delete>
, ее выбрасывают
TypeError: Невозможно прочитать свойство 'map' из неопределенного.
Есть ли какая-либо связь между
ax ios => getData => setState => .map => return elmItem
Спасибо!
class ContentComponent extends Component {
constructor(props) {
super(props);
this.state = {
items: [],
};
}
componentDidMount() {
axios
.get("http://localhost:4000/api/todos")
.then(res => this.setState({ items: res.data.result }))
.catch(error => console.log(error));
}
handleDelete = value => {
axios
.delete(`http://localhost:4000/api/todos/${value}`)
.then(res => this.setState({items: res.data.result}))
.catch(error => console.log(error));
};
render() {
let { items } = this.state;
const elmItem = items.map((item, index) => {
return <TableComponent item={item} key={index} index={index} handleDelete={this.handleDelete}/>;
});}
<table className="table">
<tbody>{elmItem}</tbody>
</table>