Skip to content

Instantly share code, notes, and snippets.

@SakoMe
Created May 16, 2019 11:20
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 SakoMe/aa1ca77e987005f03b88a10c0d64a5d8 to your computer and use it in GitHub Desktop.
Save SakoMe/aa1ca77e987005f03b88a10c0d64a5d8 to your computer and use it in GitHub Desktop.
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