Last active
April 6, 2018 15:06
-
-
Save VitorLuizC/f3d06f60cd34353c407dfdb9cf05fe22 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, { PureComponent } from 'react'; | |
| import { getPersisted, FormContainer, FormInput } from 'react-persistent-form'; | |
| class SignInForm extends PureComponent { | |
| state = { | |
| email: getPersisted('SignInForm.email') || '', | |
| password: getPersisted('SignInForm.password') || '', | |
| }; | |
| signIn () { | |
| // ... | |
| } | |
| render () { | |
| return ( | |
| <FormContainer | |
| id="SignInForm" | |
| onSubmit={() => this.signIn()} | |
| > | |
| <FormInput | |
| id="SignInForm.email" | |
| name="E-Mail" | |
| type="email" | |
| value={this.state.email} | |
| validate={(email) => !!email.trim() || 'O E-Mail precisa ser preenchido.'} | |
| onUpdate={(email) => this.setState({ email })} | |
| /> | |
| <FormInput | |
| id="SignInForm.password" | |
| name="Senha" | |
| type="password" | |
| validate={(password) => !!password.trim() || 'A senha precisa ser preenchida.'} | |
| onUpdate={(password) => this.setState({ password })} | |
| /> | |
| <button type="submit">Entrar</button> | |
| </FormContainer> | |
| ); | |
| } | |
| } | |
| export default SignInForm; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment