import React from 'react';
class ShoppingList extends React.Component {
constructor() {
super();
this.state = {
counter: 0,
}
}
onClickUp = () => {
this.setState((prevState) => {
return {
counter: prevState.counter + 1,
}
})
};
onClickDown = () => {
this.setState((prevState) => {
return {
counter: prevState.counter - 1,
}
})
};
render() {
return (
<div>
<div>
<img
src="https://s1.stc.all.kpcdn.net/putevoditel/projectid_103889/images/tild3230-3862-4039-b139-343530613431__bananas-1354785_1280.jpg"
alt=""/>
<p>Text</p>
<h1>{this.state.counter}</h1>
<button onClick={this.onClickUp}>Добвить</button>
<button onClick={this.onClickDown}>Убавить</button>
<button>Добавить в корзину</button>
</div>
<div>
<img
src="https://s1.stc.all.kpcdn.net/putevoditel/projectid_103889/images/tild3230-3862-4039-b139-343530613431__bananas-1354785_1280.jpg"
alt=""/>
<p>Text</p>
<h1>{this.state.counter}</h1>
<button onClick={this.onClickUp}>Добвить</button>
<button onClick={this.onClickDown}>Убавить</button>
<button>Добавить в корзину</button>
</div>
<div>
<img
src="https://s1.stc.all.kpcdn.net/putevoditel/projectid_103889/images/tild3230-3862-4039-b139-343530613431__bananas-1354785_1280.jpg"
alt=""/>
<p>Text</p>
<h1>{this.state.counter}</h1>
<button onClick={this.onClickUp}>Добвить</button>
<button onClick={this.onClickDown}>Убавить</button>
<button>Добавить в корзину</button>
</div>
</div>
)
}
}
export default ShoppingList;