Created
May 16, 2019 11:20
-
-
Save SakoMe/aa1ca77e987005f03b88a10c0d64a5d8 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
export default function App() { | |
const useFormInput = initialValue => { | |
const [value, setValue] = useState(initialValue); | |
const handleChange = event => setValue(event.target.value); | |
return { value: value, onChange: handleChange }; | |
}; | |
const name = useFormInput(''); | |
const password = useFormInput(''); | |
return ( | |
<form> | |
<input type='text' placeholder='name...' {...name} /> | |
<input type='password' placeholder='password' {...password} /> | |
<input type='submit' value='Add User' /> | |
</form> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment