Created
June 24, 2019 03:49
-
-
Save benawad/93f1734ba5771ea53615be6f6fd89721 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 { 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