<div id='root'></div>
button {
width:100px;
height:50px;
}
function Button(props) {
return (
<button onClick={props.onClick}>
{props.text}
</button>
)
}
class View extends React.Component {
constructor(props) {
super(props);
this.state = {isClicked: true};
}
handleClick = () => {
this.setState({isClicked: !this.state.isClicked});
}
render() {
return (
<div>
<Button
onClick={this.handleClick}
text={this.state.isClicked
? 'Вы записаны'
: 'Записаться'}/>
<Button
onClick={() => {}}
text={this.state.isClicked
? 'Отправлено'
: 'Отправить'}/>
</div>
)
}
}
ReactDOM.render(
<View />,
document.querySelector('#root')
);
View Compiled
This Pen doesn't use any external CSS resources.