Skip to content

Instantly share code, notes, and snippets.

@geetotes
Last active May 15, 2017 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geetotes/8b726bca465c81681f35e3283135dc64 to your computer and use it in GitHub Desktop.
Save geetotes/8b726bca465c81681f35e3283135dc64 to your computer and use it in GitHub Desktop.
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