Skip to content

Instantly share code, notes, and snippets.

@benawad
Created June 24, 2019 03:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benawad/3d95a0acd4be329afb05cc570ccd545c to your computer and use it in GitHub Desktop.
Save benawad/3d95a0acd4be329afb05cc570ccd545c to your computer and use it in GitHub Desktop.
export const useForm = initialValues => {
const [values, setValues] = useState(initialValues);
return [
values,
e => {
setValues({
...values,
[e.target.name]: e.target.value
});
},
// reset
() => setValues(initialValues)
];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment