import React, { Component } from 'react';
import { Field, initialize } from 'redux-form';
import withForm from 'withForm';
const FORM_NAME = 'registerForm';
const Form = withForm(FORM_NAME);
class Filter extends Component {
handleSubmit = values => {
console.log('filter', values);
}
render() {
return (
<Form onSubmit={this.handleSubmit}>
<div>
<label htmlFor="firstName">First Name</label>
<Field name="firstName" component="input" type="text" />
</div>
<div>
<label htmlFor="lastName">Last Name</label>
<Field name="lastName" component="input" type="text" />
</div>
<div>
<label htmlFor="email">Email</label>
<Field name="email" component="input" type="email" />
</div>
<button type="submit">Submit</button>
</Form>
);
}
}
export default Filter;
Last active
December 6, 2018 16:24
-
-
Save davidnguyen11/7353445a1fac97f71931cede2111f8f1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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'; | |
| import PropTypes from 'prop-types'; | |
| import { reduxForm } from 'redux-form'; | |
| function withForm(formName) { | |
| function FormWrapper(props) { | |
| const { handleSubmit } = props; | |
| return ( | |
| <form onSubmit={handleSubmit}> | |
| {props.children} | |
| </form> | |
| ); | |
| } | |
| FormWrapper.propTypes = { | |
| handleSubmit: PropTypes.func, | |
| children: PropTypes.any, | |
| }; | |
| FormWrapper.defaultProps = { | |
| handleSubmit: () => {}, | |
| children: {}, | |
| }; | |
| return reduxForm({ | |
| form: formName, | |
| })(FormWrapper); | |
| } | |
| export default withForm; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment