Skip to content

Instantly share code, notes, and snippets.

@izabellewilding
Created July 9, 2020 20:50
Show Gist options
  • Save izabellewilding/e37d954c108b882042805398b619f762 to your computer and use it in GitHub Desktop.
Save izabellewilding/e37d954c108b882042805398b619f762 to your computer and use it in GitHub Desktop.
export default class ExampleComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
name: "John"
};
this.changeName = this.changeName.bind(this);
}
changeName() {
this.setState({ name: "Bob" });
}
render() {
return <h1 onClick={this.changeName}>{this.state.name}</h1>;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment