Created
July 9, 2020 20:50
-
-
Save izabellewilding/e37d954c108b882042805398b619f762 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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