SS
addSpecification = ( e ) => {Как можно вот это отрефакторить, чтобы вместо specifications прилетали любые другие поля, чтобы обработчик события стал универсальным?
const target = e.target.getAttribute('data-target')
this.setState(( { specifications } ) => ( {
specifications: { ...specifications, count: specifications.count + 1 },
} ))
}
addSpecification = (name, value) => ( e ) => {
this.setState({
[name]: value
})
}
<div onClick={addSpecification(‘specifications’, this.state.specifications + 1)}>Text</div>