Last active
May 15, 2017 19:49
-
-
Save geetotes/8b726bca465c81681f35e3283135dc64 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
class SignUpForm extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
email: null, | |
username: null, | |
}; | |
this._change = this._change.bind(this); | |
this._validate = this._validate.bind(this); | |
} | |
_change(e) { | |
this.setState({ | |
[e.target.name]: e.target.value | |
}); | |
} | |
_validate() { | |
// Do validations here! | |
} | |
render() { | |
return( | |
<form> | |
Usernane: <input type='text' name='username' value={this.state.username} onChange={this._change} /> | |
Email: <input type='email' name='email' value={this.state.email} onChange={this._change} /> | |
<button onClick={this._validate}>Submit</button> | |
</form> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment