Skip to content

Instantly share code, notes, and snippets.

@Mayankgupta688
Created May 7, 2019 10:33
Show Gist options
  • Select an option

  • Save Mayankgupta688/aa27dff6a0a057424b829a86cfce9f72 to your computer and use it in GitHub Desktop.

Select an option

Save Mayankgupta688/aa27dff6a0a057424b829a86cfce9f72 to your computer and use it in GitHub Desktop.
class EmployeeDetails extends React.Component {
constructor() {
super();
this.state = {
name: "Mayank",
age: 31,
designation: "Senior Developer"
}
}
updateEmployeeAge = () => {
this.setState({
age: this.state.age + 1
});
}
render() {
return (
<div>
<p>Employee Name: {this.state.name}</p>
<p>Employee Age: {this.state.name}</p>
<p>Employee Designation: {this.state.designation}</p>
<input type="button" onClick={this.updateEmployeeAge} value="Click To Update Age" />
</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment