Created
October 10, 2019 13:54
-
-
Save tgmarinho/e551383fedbec22d1d5b202e31a0a745 to your computer and use it in GitHub Desktop.
Form com React Hooks e Unform
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
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