Created
June 24, 2019 03:43
-
-
Save benawad/3d95a0acd4be329afb05cc570ccd545c 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 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