Skip to content

Instantly share code, notes, and snippets.

@blizzerand
Created November 28, 2018 13:31
Show Gist options
  • Save blizzerand/138daf70c5b05aaf3c2074a8e25a4ff6 to your computer and use it in GitHub Desktop.
Save blizzerand/138daf70c5b05aaf3c2074a8e25a4ff6 to your computer and use it in GitHub Desktop.
Form Container
import React, {Component} from 'react';
/* Import Presentational Components */
import CheckBox from '../components/CheckBox';
import Input from '../components/Input';
class FormContainer extends Component {
constructor(props) {
super(props);
/*Initialize the state */
this.state = {
newUser: {
name: '',
email: '',
age: '',
gender: '',
expertise: '',
about: ''
},
genderOptions: ['Male', 'Female', 'Others'],
skillOptions: ['Programming', 'Development', 'Design', 'Testing']
}
this.handleFormSubmit = this.handleFormSubmit.bind(this);
this.handleClearForm = this.handleClearForm.bind(this);
}
/* This life cycle hook gets executed when the component mounts */
handleFormSubmit() {
// Form submission logic
}
handleClearForm() {
// Logic for resetting the form
}
render() {
return (
<form className="container" onSubmit={this.handleFormSubmit}>
<Input /> {/* Name of the user */}
<Input /> {/* Input for Age */}
<Select /> {/* Gender Selection */}
<CheckBox /> {/* List of Skills (eg. Programmer, developer) */}
<TextArea /> {/* About you */}
<Button /> { /*Submit */ }
<Button /> {/* Clear the form */}
</form>
);
}
}
export default FormContainer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment