Last active
July 7, 2019 14:25
-
-
Save benfluleck/05d63db9c98f889e9bbdd9ab1ff6c5bf 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
import React from 'react' | |
import Text from '<atoms>/Text/Text' | |
import { useState } from 'react' | |
export const useForm = (initialValues) => { | |
const [values, setValues] = useState(initialValues) | |
return [ | |
values, | |
e => { | |
setValues({ | |
...values, | |
[e.target.name]: e.target.value | |
}) | |
} | |
] | |
} | |
const HomePage = () => { | |
const [values, handleChange] = useForm({ email: '', password: '' }) | |
return( | |
<div> | |
<input name='password' type="password" value={values.password} | |
onChange={ | |
handleChange | |
} | |
/> | |
<input name='email' type="email" value={values.email} | |
onChange={ | |
handleChange | |
} | |
/> | |
</div> | |
) | |
} | |
export default HomePage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment