class Buttons extends Component {
state = {
foo: 'bar'
}
changeText = () => {
if (this.state.foo === 'bar') {
this.setState({ foo: 'foo' })
} else {
this.setState({ foo: 'bar' })
}
}
render() {
return (
<Button text={this.foo} />
<Button text={this.foo} />
<Button text={this.foo} />
<Button text={'Изменить текст'} onClick={this.changeText} />
)
}
}