Skip to content

Instantly share code, notes, and snippets.

@RealDeanZhao
Created July 24, 2016 05:05
Show Gist options
  • Save RealDeanZhao/41f8211d463e99210b01ae6644b35736 to your computer and use it in GitHub Desktop.
Save RealDeanZhao/41f8211d463e99210b01ae6644b35736 to your computer and use it in GitHub Desktop.
// a Form
class FormBase extends React.Component<any, {}>{
render() {
return (
<form onSubmit={this.props.handleSubmit}>
<div>
<label>Username</label>
<Field component='input' className="form-control" type="text" placeholder="First Name" name='username'/>
</div>
</form>
)
}
}
export const Form = reduxForm({
form: 'form'
})(FormBase);
// The component with a Form
class OuterBase extends React.Component<any, {}>{
// the values will be passed from the inner Form component, so we can do some dispatching here.
handleSubmit = (values: any): any => {
const {dispatch} = this.props;
const {username, password} = values;
dispatch();
}
render() {
return (
<div>
<Form onSubmit={this.handleSubmit} />
</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment