class Person extends React.Component {
state ={
age:36
}
render() {
return (
<div>
<h1>Hello, world!</h1>
<h2>I am {this.state.age} years old.</h2>
</div>
);
}
}
class Person extends Component{
state = {
age: 36
}
haveBirthday = () => {
this.setState({
age: this.state.age + 1,
})
}
render() {
return (
<div>
You are {this.state.age}
<button onClick={this.haveBirthday}>Have Birthday</button>
</div>
);
}
}
class Person extends Component{
state = {
age: 36
}
haveBirthday = () => {
this.setState({
age: this.state.age + 1,
isBirthday: true
})
}
render() {
return (
<div>
You are {this.state.age}
<button onClick={this.haveBirthday}>Have Birthday</button>
</div>
);
}
}