class App extends React.Component {
constructor(props) {
super(props);
this.state = {
text: '',
count: 0,
}
}
showText = () => {
console.log('button work');
this.setState({ text: 'button work' });
}
showCount = () => {
this.setState({ text: '0' });
}
render() {
return (
<div>
<button onClick={this.showText}>Push1</button>
<p>{this.state.text}</p>
<button onClick={this.showCount}>Count</button>
<p>{this.state.count}</p>
</div>
)
}
}
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
text: '',
count: 0,
}
}
showText = () => {
console.log('button work');
this.setState({ text: 'button work' });
}
showCount = () => {
this.setState({ count: '0' });
}
render() {
return (
<div>
<button onClick={this.showText}>Push1</button>
<p>{this.state.text}</p>
<button onClick={this.showCount}>Count</button>
<p>{this.state.count}</p>
</div>
)
}
}