Skip to content

Instantly share code, notes, and snippets.

@VitorLuizC
Last active April 6, 2018 15:06
Show Gist options
  • Select an option

  • Save VitorLuizC/f3d06f60cd34353c407dfdb9cf05fe22 to your computer and use it in GitHub Desktop.

Select an option

Save VitorLuizC/f3d06f60cd34353c407dfdb9cf05fe22 to your computer and use it in GitHub Desktop.
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