class Item extends Component {
render() {
function selectItem(e) {
alert('test');
}
return (
<div className={s.item} onClick={selectItem}>
<div className={s.pic}>pic</div>
<div className={s.product}>Name</div>
<div className={s.lowprice}>9999RUB</div>
<div className={s.sale}>54%</div>
</div>
);
}
}
class Item extends Component {
state = {selected: false}
toggleSelected = () => { this.setState({selected: !this.state.selected}) }
render() {
return (
<div className={`${s.item} ${this.state.selected ? 'selected' : ''}`} onClick={this.toggleSelected}>
<div className={s.pic}>pic</div>
<div className={s.product}>Name</div>
<div className={s.lowprice}>9999RUB</div>
<div className={s.sale}>54%</div>
</div>
);
}
}