import React from 'react';
import './App.css';
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: '11' });
}
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>
)
}
}
export default App;
import React from 'react';
import './App.css';
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: this.state.count + 1});
}
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>
)
}
}
export default App;