Skip to content

Instantly share code, notes, and snippets.

@benawad
Created June 24, 2019 03:49
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 benawad/93f1734ba5771ea53615be6f6fd89721 to your computer and use it in GitHub Desktop.
Save benawad/93f1734ba5771ea53615be6f6fd89721 to your computer and use it in GitHub Desktop.
import { useState } from "react";
export const useForm = <T>(initialValues: T) => {
const [values, setValues] = useState(initialValues);
return [
values,
(e: any) => {
setValues({
...values,
[e.target.name]: e.target.value
});
}
];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment