Last active
July 13, 2017 22:31
-
-
Save SherryH/a54acda1dae00540e3dcc7a327203e5b 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
import react from 'react'; | |
class Person extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
name: '' | |
}; | |
//there is no need to bind event handlers here :) | |
} | |
//notice! class methods are defined as arrow functions! | |
handleChange = (e) => { | |
this.setState({ | |
name: e.target.value | |
}); | |
} | |
render() { | |
return ( | |
<div> | |
<input value={this.state.name} onChange={this.handleChange} /> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment