Skip to content

Instantly share code, notes, and snippets.

@tgmarinho
Created October 10, 2019 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgmarinho/e551383fedbec22d1d5b202e31a0a745 to your computer and use it in GitHub Desktop.
Save tgmarinho/e551383fedbec22d1d5b202e31a0a745 to your computer and use it in GitHub Desktop.
Form com React Hooks e Unform
import React from 'react';
import { Form, Input } from '@rocketseat/unform';
import { useSelector } from 'react-redux';
import { Container } from './styles';
export default function Profile() {
const profile = useSelector(state => state.user.profile);
function handleSubmit(data) {
console.tron.log(data);
}
return (
<Container>
<Form initialData={profile} onSubmit={handleSubmit}>
<Input name="name" placeholder="Nome completo" />
<Input name="email" placeholder="Seu endereço completo" />
<hr />
<Input
type="password"
name="oldPassword"
placeholder="Sua senha atual"
/>
<Input type="password" name="password" placeholder="Nova senha" />
<Input
type="password"
name="confirmPassword"
placeholder="Confirmação de senha"
/>
<button type="submit">Atualizar perfil</button>
</Form>
<button type="submit">Sair do Gobarber</button>
</Container>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment