Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SignUpForm extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- username: '',
- email: '',
- password: ''
- };
- }
- handleChange(field) {
- return (e) => {
- this.setState({...this.state, [field]: e.target.value});
- };
- }
- handleSubmit(e) {
- e.preventDefault();
- this.props.onSubmit(this.state);
- }
- render() {
- return (
- <form onSubmit={this.handleSubmit.bind(this)}>
- <input type="text"
- value={this.state.username}
- onChange={this.handleChange('username').bind(this)}
- placeholder="Username" />
- <input type="text"
- value={this.state.email}
- onChange={this.handleChange('email').bind(this)}
- placeholder="Email" />
- <input type="password"
- value={this.state.password}
- onChange={this.handleChange('password').bind(this)}
- placeholder="Password" />
- <input type="submit" value="Sign Up!!"/>
- </form>
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement