Created
February 25, 2018 20:31
-
-
Save ericvaladas/3d25a40973562bf4de1e24302d2087d1 to your computer and use it in GitHub Desktop.
This file contains 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
const Input = (props, state, validate) => { | |
return ( | |
<div> | |
<input {...props} onChange={e => props.onChange(e).then(validate)}/> | |
<span>{state.message}</span> | |
</div> | |
); | |
} | |
class App extends Component { | |
handleSubmit(form) { | |
console.log(form.values); | |
} | |
render() { | |
return ( | |
<Form onSubmit={form => this.handleSubmit(form)}> | |
<Field name="username" validators={[minLength(3)]}> | |
{Input} | |
</Field> | |
<Field name="password" type="password" validators={[minLength(6)]}> | |
{Input} | |
</Field> | |
<button>Submit</button> | |
</Form> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment